Exemplo n.º 1
0
        public DisplayingEventsController(IConnectionController connectionServiceController)
        {
            ITransport currentTransport = connectionServiceController.CurrentTransport ??
                                          throw new ArgumentNullException(nameof(connectionServiceController));

            currentTransport.UpdatedDataBaseData += HandleUpdatedDataBaseClients;
        }
Exemplo n.º 2
0
        public void UpdateRemove(int ID, double quantity, double sell)
        {
            cmd             = new SqlCommand();
            cmd.CommandText = "UPDATE Products SET Quantity = @quantity, Sell = @sell WHERE ID = @id";
            connection      = new ConnectionController();

            cmd.Parameters.AddWithValue("@quantity", quantity);
            cmd.Parameters.AddWithValue("@sell", sell);
            cmd.Parameters.AddWithValue("@id", ID);

            try
            {
                //Object
                connection = new ConnectionController();
                //Connect to the DB
                cmd.Connection = connection.Connect();
                //Execute command
                cmd.ExecuteNonQuery();
                //Disconnect
                cmd.Connection = connection.Disconnect();
            }
            catch (SqlException)
            {
                Console.WriteLine("Erro ao alterar dados no Banco.");
            }
            finally
            {
                //Disconnect the DB
                cmd.Connection = connection.Disconnect();
            }
        }
Exemplo n.º 3
0
 public ChatPanelController(IConnectionController connectionServiceController)
 {
     _currentTransport                   = connectionServiceController.CurrentTransport ?? throw new ArgumentNullException(nameof(connectionServiceController));
     _connectionServiceController        = connectionServiceController;
     _currentTransport.MessageReceived  += HandleMessageReceived;
     _currentTransport.UpdatedUsersList += HandleUpdatedUsersList;
 }
Exemplo n.º 4
0
 public AddEdgeTool(
     IModelFactory modelFactory,
     IEdge feedback,
     IConnectionController controller
     ) :
     this(modelFactory, feedback, controller.CanConnectSource, controller.CanConnectTarget, null)
 {
 }
Exemplo n.º 5
0
 public AddEdgeTool(
     IModelFactory modelFactory,
     IEdge feedback,
     IConnectionController controller,
     Action <IEdge> edgeInitializer
     ) :
     this(modelFactory, feedback, controller.CanConnectSource, controller.CanConnectTarget, edgeInitializer)
 {
 }
Exemplo n.º 6
0
 internal BlockExchanger(string configPath, BlockExchangerOptions options,
                         IObjectStoreFactory objectStoreFactory, IConnectionController connectionController,
                         INodeExplorer nodeExplorer, IPublishStorage publishStorage, IWantStorage wantStorage, IBytesPool bytesPool)
 {
     _configPath           = configPath;
     _options              = options;
     _objectStoreFactory   = objectStoreFactory;
     _connectionController = connectionController;
     _nodeExplorer         = nodeExplorer;
     _publishStorage       = publishStorage;
     _wantStorage          = wantStorage;
     _bytesPool            = bytesPool;
 }
Exemplo n.º 7
0
        public TelloController(ILoggerFactory loggerFactory,
                               TelloSettings settings,
                               IConnectionController controller)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            logger               = loggerFactory.CreateLogger <TelloController>();
            Settings             = settings ?? throw new ArgumentNullException(nameof(settings));
            ConnectionController = controller ?? throw new ArgumentNullException(nameof(controller));
        }
Exemplo n.º 8
0
    void Start()
    {
        // Test
        Connection = FindObjectOfType <ConnectionController>();
        var gatewayConnectionListener = new GenericConnectionListener(UpdateConnectionStatus);

        Connection.SetConnectionListener(gatewayConnectionListener);
        gatewayConnectionListener.SetMessageListener(this);

        if (!ConnectToLastServer())
        {
            ConnectTo("ws://127.0.0.1:2999");
        }

        UpdateConnectionStatus();
    }
Exemplo n.º 9
0
        internal NodeExplorer(string configPath, NodeExplorerOptions options,
                              IObjectStoreFactory objectStoreFactory, IConnectionController connectionController,
                              IPublishStorage publishStorage, IWantStorage wantStorage, IBytesPool bytesPool)
        {
            _configPath           = configPath;
            _options              = options;
            _objectStoreFactory   = objectStoreFactory;
            _connectionController = connectionController;
            _publishStorage       = publishStorage;
            _wantStorage          = wantStorage;
            _bytesPool            = bytesPool;

            {
                var id = new byte[32];
                using var random = RandomNumberGenerator.Create();
                random.GetBytes(id);
                _myId = id;
            }
        }
        void ConnectionView_Loaded(object sender, RoutedEventArgs e)
        {
            //initialise connection view from appropriate controller
            //TODO: get view based on connection type

            var displaySize = (Size)PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice.Transform(new Vector(this.ActualWidth, this.ActualHeight));

            connectionController = new RDPConnectionController
            {
                DesktopResolution = new Size(displaySize.Width, displaySize.Height),
                Model             = ViewModel
            };

            ViewModel.DisconnectRequested += (s, se) =>
            {
                connectionController.Disconnect();
            };
            connectionController.Disconnected += (s, se) =>
            {
                ViewModel.OnDisconnected(se);
            };

            System.Windows.Forms.Panel container = new System.Windows.Forms.Panel();
            container.Dock = System.Windows.Forms.DockStyle.Fill;
            formHost.Child = container;

            var rdpConnection = connectionController.ConnectionView;

            rdpConnection.Dock   = System.Windows.Forms.DockStyle.Fill;
            rdpConnection.Parent = container;

            rdpConnection.CreateControl();

            this.GotFocus += new RoutedEventHandler(ConnectionView_GotFocus);

            connectionController.CreateControl();
            connectionController.Connect();

            //make sure all events fire
            System.Windows.Forms.Application.DoEvents();
        }
Exemplo n.º 11
0
    void Start()
    {
        Connection = FindObjectOfType<ConnectionController>();

        if (Connection == null || !Connection.IsConnected)
        {
            Application.LoadLevel("login");
            return;
        }

        Connection.SendMessage(MessageCode.GameLoad, new JSONObject(), m =>
        {
            var posData = m.GetField("position");
            var position = HelperMethods.PositionFromJSONArray(posData);

            var loadingData = new ZoneLoadData(position, "Super WOrld", "world");
            PersistentData.ZoneLoadData = loadingData;

            Application.LoadLevel("gameplay");
        });
    }
Exemplo n.º 12
0
    void Start()
    {
        Connection = FindObjectOfType <ConnectionController>();

        if (Connection == null || !Connection.IsConnected)
        {
            Application.LoadLevel("login");
            return;
        }

        Connection.SendMessage(MessageCode.GameLoad, new JSONObject(), m =>
        {
            var posData  = m.GetField("position");
            var position = HelperMethods.PositionFromJSONArray(posData);

            var loadingData             = new ZoneLoadData(position, "Super WOrld", "world");
            PersistentData.ZoneLoadData = loadingData;

            Application.LoadLevel("gameplay");
        });
    }
Exemplo n.º 13
0
        //Insert in DB
        public void InsertDB(Product p)
        {
            connection = new ConnectionController();
            SqlConnection sc = new SqlConnection();

            sc = connection.Cn;

            //SQL Command
            cmd = new SqlCommand("INSERT INTO Products (Name, Quantity, PurchasePrice, SalePrice, Buy, Sell)" +
                                 "values (@Name, @Quantity, @PurchasePrice, @SalePrice, @Buy, @Sell)", sc);

            //Parameters
            cmd.Parameters.AddWithValue("@Name", p.Name);
            cmd.Parameters.AddWithValue("@Quantity", p.Quantity);
            cmd.Parameters.AddWithValue("@PurchasePrice", p.PurchasePrice);
            cmd.Parameters.AddWithValue("@SalePrice", p.SalePrice);
            cmd.Parameters.AddWithValue("@Buy", p.Buy);
            cmd.Parameters.AddWithValue("@Sell", p.Sell);

            try
            {
                //Object
                connection = new ConnectionController();
                //Connect to the DB
                cmd.Connection = connection.Connect();
                //Execute command
                cmd.ExecuteNonQuery();
                //Disconnect the DB
                cmd.Connection = connection.Disconnect();
            }
            catch (SqlException)
            {
                Console.WriteLine("Nome do produto excede o limite para registro, tente novamente.");
            }
            finally
            {
                connection.Disconnect();
            }
        }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        Connection = FindObjectOfType<ConnectionController>();

        if (Connection == null || !Connection.IsConnected)
        {
            Application.LoadLevel("login");
            return;
        }

        var gatewayConnectionListener = new GenericConnectionListener(UpdateConnectionStatus);
        gatewayConnectionListener.SetMessageListener(this);
        Connection.SetConnectionListener(gatewayConnectionListener);

        DontDestroyOnLoad(this);
        DontDestroyOnLoad(Player);

        // Setup player
        Player.transform.position = PersistentData.ZoneLoadData.PlayerPosition;

        Application.LoadLevel("world");
        Connection.SendMessage(MessageCode.PlayerInGame, new JSONObject());
    }
Exemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        Connection = FindObjectOfType <ConnectionController>();

        if (Connection == null || !Connection.IsConnected)
        {
            Application.LoadLevel("login");
            return;
        }

        var gatewayConnectionListener = new GenericConnectionListener(UpdateConnectionStatus);

        gatewayConnectionListener.SetMessageListener(this);
        Connection.SetConnectionListener(gatewayConnectionListener);

        DontDestroyOnLoad(this);
        DontDestroyOnLoad(Player);

        // Setup player
        Player.transform.position = PersistentData.ZoneLoadData.PlayerPosition;

        Application.LoadLevel("world");
        Connection.SendMessage(MessageCode.PlayerInGame, new JSONObject());
    }
Exemplo n.º 16
0
        public void Connect(string address, int port, string login, InterfaceType interfaceType)
        {
            _connectionController = null;
            switch (interfaceType)
            {
            case InterfaceType.WebSocket:
                _connectionController = new WsNetworkController();
                break;

            case InterfaceType.Tcp:
                _connectionController = new TcpNetworkController();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(Type), interfaceType, null);
            }

            _connectionController.Connect(address, port, login);
            _connectionController.ConnectionStateChanged += HandleConnectionStateChanged;
            _connectionController.Login           += HandleLogin;
            _connectionController.MessageReceived += HandleMessageReceived;
            _connectionController.UpdateChannel   += HandleUpdateChannel;
            _connectionController.LogEvent        += HandleLog;
        }
Exemplo n.º 17
0
        protected ICommandResult PotatoRemoveConnection(ICommand command, IConnectionController connection) {
            ICommandResult result = null;

            // As long as the current account is allowed to execute this command...
            if (this.Shared.Security.DispatchPermissionsCheck(command, command.Name).Success == true) {

                // As long as the connection for that specific game, hostname, and port exists...
                if (connection != null) {
                    lock (this.Connections) {
                        this.Connections.Remove(connection);
                    }

                    result = new CommandResult() {
                        Message = String.Format(@"Successfully removed connection with connection to {0}:{1} and game type ""{2}"".", connection.ConnectionModel.Hostname, connection.ConnectionModel.Port, connection),
                        CommandResultType = CommandResultType.Success,
                        Success = true,
                        Now = {
                            Connections = new List<ConnectionModel>() {
                                connection.ConnectionModel
                            }
                        }
                    };

                    this.Shared.Events.Log(GenericEvent.ConvertToGenericEvent(result, GenericEventType.PotatoConnectionRemoved));

                    connection.Dispose();
                }
                else {
                    result = new CommandResult() {
                        Message = String.Format(@"Connection does not exist."),
                        CommandResultType = CommandResultType.DoesNotExists,
                        Success = false
                    };
                }
            }
            else {
                result = CommandResult.InsufficientPermissions;
            }

            return result;
        }
Exemplo n.º 18
0
        public void SelectDB(List <Product> list)
        {
            cmd = new SqlCommand();

            //SQL Command
            cmd.CommandText = "SELECT * FROM Products";

            try
            {
                //Object
                connection = new ConnectionController();
                Product       p;
                SqlDataReader reader;

                //Connect to the DB
                cmd.Connection = connection.Connect();
                //Execute command
                reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    //Loop to read the rows and set in the object
                    while (reader.Read())
                    {
                        p    = new Product();
                        p.ID = Convert.ToInt32(reader["ID"].ToString());

                        //Repeated data test by ID
                        if (!(p.ID <= list.Count))
                        {
                            p.Name          = reader["Name"].ToString();
                            p.Quantity      = Convert.ToInt32(reader["Quantity"].ToString());
                            p.PurchasePrice = double.Parse(reader["PurchasePrice"].ToString());
                            p.SalePrice     = double.Parse(reader["SalePrice"].ToString());
                            p.Buy           = double.Parse(reader["Buy"].ToString());
                            p.Sell          = double.Parse(reader["Sell"].ToString());

                            list.Add(p);
                        }
                        else
                        {
                            list[p.ID - 1].Name          = reader["Name"].ToString();
                            list[p.ID - 1].Quantity      = Convert.ToInt32(reader["Quantity"].ToString());
                            list[p.ID - 1].PurchasePrice = double.Parse(reader["PurchasePrice"].ToString());
                            list[p.ID - 1].SalePrice     = double.Parse(reader["SalePrice"].ToString());
                            list[p.ID - 1].Buy           = double.Parse(reader["Buy"].ToString());
                            list[p.ID - 1].Sell          = double.Parse(reader["Sell"].ToString());
                        }
                    } //end while
                }     //end if
                reader.Close();
            }         //Disconnect the DB
            catch (SqlException)
            {
                Console.WriteLine("Erro ao conectar ao banco de dados, tente novamente");
            }
            finally
            {
                connection.Disconnect();
            }
        }//end selectDB
Exemplo n.º 19
0
            public async ValueTask <INodeExplorer> CreateAsync(string configPath, NodeExplorerOptions options,
                                                               IObjectStoreFactory objectStoreFactory, IConnectionController connectionController,
                                                               IPublishStorage publishStorage, IWantStorage wantStorage, IBytesPool bytesPool)
            {
                var result = new NodeExplorer(configPath, options, objectStoreFactory, connectionController, publishStorage, wantStorage, bytesPool);
                await result.InitAsync();

                return(result);
            }
 /// <summary>
 /// ctor
 /// </summary>
 public DefaultDatabaseAccess(IConnectionController connectionController)
 {
     ConnectionController = connectionController;
 }
Exemplo n.º 21
0
    void Start()
    {
        // Test
        Connection = FindObjectOfType<ConnectionController>();
        var gatewayConnectionListener = new GenericConnectionListener(UpdateConnectionStatus);
        Connection.SetConnectionListener(gatewayConnectionListener);
        gatewayConnectionListener.SetMessageListener(this);

        if (!ConnectToLastServer())
        {
            ConnectTo("ws://127.0.0.1:2999");
        }

        UpdateConnectionStatus();
    }
 public ConnectionControllerStateMachine(IConnectionController controller)
 {
     _controller = controller;
 }