/// <summary> /// Initializes a new instance. /// </summary> /// <param name="link">The link this instance will be associated with.</param> public QueryCommand(IDataLink link) : base(link) { if ((_Aliases = Link.Engine.CreateElementAliasCollection()) == null) throw new CannotCreateException( "Cannot create a collection of aliases for this instance."); }
public static void insertPartido(Partidos partido, IDataLink kConnection) { kConnection.Open(); var insert = kConnection.Raw("INSERT INTO [dbo].[partidos] ([equipo1], [marcador1], [equipo2], [marcador2], [estadio]) VALUES("+ partido.Equipo1 +", null, "+ partido.Equipo2 +", null, " + partido.Estadio + ")"); insert.Execute(); kConnection.Close(); }
public void IncomingDataToReceiver() { int messageTarget = 1; string messageData = "Test message data"; Message expectedMessage = new Message { id = messageTarget, stringData = messageData }; Message sourceMessage = new Message { id = messageTarget, stringData = messageData }; ProtoBufPresentation pbPres = new ProtoBufPresentation(); DummyMessageReceiver receiver = new DummyMessageReceiver(expectedMessage); pbPres.SetReceiver(receiver); byte[] binaryMessage = pbPres.MessageToBinaryData(sourceMessage); IDataLink datalink = NSubstitute.Substitute.For <IDataLink>(); pbPres.IncomingData(binaryMessage, datalink); pbPres.IncomingData(binaryMessage, datalink); byte[] firstHalf = new byte[6]; byte[] secondHalf = new byte[binaryMessage.Length - 6]; Array.Copy(binaryMessage, 0, firstHalf, 0, 6); Array.Copy(binaryMessage, 6, secondHalf, 0, binaryMessage.Length - 6); pbPres.IncomingData(firstHalf, datalink); pbPres.IncomingData(secondHalf, datalink); }
public ILinkWriter CreateWriter(IDataLink link, string table) { SqlDataWriter writer = new SqlDataWriter(); writer.Initialize(link); return(writer); }
public unsafe PacketCommunicatorReceiveResult ReceivePacket(out Packet packet) { this.AssertMode(PacketCommunicatorMode.Capture); pcap_pkthdr *pcapPkthdrPtr1; byte * numPtr; PacketCommunicatorReceiveResult communicatorReceiveResult = this.RunPcapNextEx(&pcapPkthdrPtr1, &numPtr); if (communicatorReceiveResult != PacketCommunicatorReceiveResult.Ok) { packet = (Packet)null; return(communicatorReceiveResult); } IDataLink dataLink = (IDataLink) new PcapDataLink(\u003CModule\u003E.pcap_datalink(this._pcapDescriptor)); byte * unmanagedByteArray = numPtr; pcap_pkthdr *pcapPkthdrPtr2 = pcapPkthdrPtr1; DateTime dateTime = new DateTime(); PacketTimestamp.PcapTimestampToDateTime((timeval *)pcapPkthdrPtr1, out dateTime); int offset = 0; int count = *(int *)((IntPtr)pcapPkthdrPtr2 + 8L); byte[] data = MarshalingServices.UnamangedToManagedByteArray(unmanagedByteArray, offset, count); packet = new Packet(data, dateTime, dataLink); return(PacketCommunicatorReceiveResult.Ok); }
public static object getPartidos(IDataLink kConnection) { kConnection.Open(); var partidos = kConnection.Raw("select p.id, e.nombre as equipo1, p.marcador1, e2.nombre as equipo2, p.marcador2, es.nombre as estadio from [keroseneDB].[dbo].[partidos] p inner join[keroseneDB].[dbo].[equipos] e on e.id = p.equipo1 inner join[keroseneDB].[dbo].[equipos] e2 on e2.id = p.equipo2 inner join[keroseneDB].[dbo].[estadios] es on es.id = p.estadio").ToList(); kConnection.Close(); return partidos; }
/* * IncomingMessage is used to receive the information from connections. * It is expected that the message contains identification information. * From the identification we'll know whether this connection represents a robot and what type. */ public void IncomingMessage(Message newMessage, IDataLink dataLink) { Debug.Log("[RobotRegister] incoming message: " + newMessage.messageType.ToString()); /* * Check if dataLink is a client connected through this listener */ Communicator connection = GetCommunicatorFromDataLink(dataLink); if (connection == null)//datalink is not a client from this listener { return; } //TODO: is identification message and message is that of a robot if (true) { /* * First wait for the other identification messages to be processed to prevent race conditions */ if (_ev.WaitOne(10000)) { _ev.Reset(); _connection = connection; _newMessage = newMessage; _continueRegistration = true; _ev.WaitOne(1000); } } }
public CommandLink(IDataLink dataLink) { this.dataLink = dataLink; this.incomingCommands = new Subject <string>(); this.dataLink.DataReceived.Subscribe(this.OnNewData); /* * var thread = new System.Threading.Thread(() => { * System.Threading.Thread.Sleep(10000); * this.incomingCommands.OnNext("PIDM 20"); * this.incomingCommands.OnNext("PIDM 20"); * this.incomingCommands.OnNext("PIDM 20"); * this.incomingCommands.OnNext("FV 0 33"); * this.incomingCommands.OnNext("FV 8 44"); * this.incomingCommands.OnNext("PID A 1 2 3 4"); * this.incomingCommands.OnNext("PID B 5 6 7 8"); * this.incomingCommands.OnNext("PID C 9 10 11 12"); * this.incomingCommands.OnNext("PID D 13 14 15 16"); * this.incomingCommands.OnNext("PID E 17 18 19 20"); * this.incomingCommands.OnNext("PID F 21 22 23 24"); * }); * thread.Start(); */ }
public ILinkReader CreateReader(IDataLink link, string query) { OleDbDataReader reader = new OleDbDataReader(); reader.Initialize(link); reader.Command = query; return reader; }
/* * IncomingNewDataLink is used to accept new connections from the listener. */ public void IncomingNewDataLink(IDataLink dataLink, IPresentationProtocol usedProtocol) { Debug.Log("[RobotRegister] incoming new connection!"); // Change the receiver of the incoming messages for given client (connection) to this class. // The information is used to check the identity of the connection. usedProtocol.SetReceiver(this); // Communicator is a management class for protocol and datalink Communicator communicator = new Communicator(dataLink, usedProtocol); // Ask for identification of the connection; might be a robot! Message id_request = MessageBuilder.CreateMessage(MessageTarget_.Robot, MessageType_.IdentificationRequest); Thread.Sleep(1); if (!communicator.SendCommand(id_request)) { Debug.LogError("[RobotRegister] Sending identity request command fails, how could this happen!?"); // Actually, it could happen if the connection is immediately closed after making it. } else { // Keep a list of the active connections communicators.Add(communicator); } }
public void IncomingMessage(Message newMessage, IDataLink dataLink) { Console.WriteLine("Received message: {0}", newMessage.messageType.ToString()); switch (newMessage.messageType) { // When Unity detects a new robot a request for identification will be send. case MessageType_.IdentificationRequest: _robot.IdentificationRequest(newMessage.id); break; // Used to changed the linear and/or angular velocity of a robot. case MessageType_.VelocityChange: _robot.VelocitySet(newMessage.robotVelocity); break; case MessageType_.RotationRequest: _robot.OnRotationRequest(); break; // Used to make the robot show some kind of signal. case MessageType_.Indicate: _robot.Indicate(); break; // Message type for custom messages/events. This can be used to interact // with robot specific functions. case MessageType_.CustomMessage: _robot.OnNonStandardMessage(newMessage); break; } }
public void IncomingData(byte[] data, IDataLink datalink) { receivedData = true; failed = !(Encoding.ASCII.GetString(data).CompareTo( Encoding.ASCII.GetString(expectedResult)) == 0); }
public void IncomingNewDataLink(IDataLink dataLink, IPresentationProtocol usedProtocol) { this.DataLink = dataLink; usedProtocol.SetReceiver(this); Connected = true; Debug.Log("Incoming impl"); }
public static object getEstadios(IDataLink kConnection) { kConnection.Open(); var estadios = kConnection.Raw("select * from estadios").ToList(); kConnection.Close(); return estadios; }
/// <summary> /// Returns the name of an existing table in the database that matches with the source /// one given, or with any of the candidates built using that source. /// </summary> internal static string FindTableName(IDataLink link, string source) { var names = new List<string>(); names.Add(source); names.AddRange(TableNameCandidates(source)); foreach (var name in names) { var found = false; var cmd = link.From(x => name).Top(1); var rec = (IRecord)null; var wasopen = link.IsOpen; try { rec = (IRecord)cmd.First(); found = true; } catch { } finally { if (rec != null) rec.Dispose(disposeSchema: true); if (cmd != null) cmd.Dispose(); if (!wasopen && link.IsOpen) link.Close(); } if (found) return name; } return null; }
public ILinkReader CreateReader(IDataLink link, string query) { // Query is irrevalent - the text file name is in the query string TextReader reader = new TextReader(); reader.Initialize(link); return reader; }
public static void updateEstadio(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var estadioEdit = kConnection.Raw("UPDATE[dbo].[estadios] SET[nombre] = '" + estadio.Nombre + "',[localidad] = '" + estadio.Localidad + "' WHERE id = " + estadio.Id); estadioEdit.Execute(); kConnection.Close(); }
public static void insertEstadio(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var insert = kConnection.Raw("INSERT INTO [dbo].[estadios] ([nombre], [localidad]) VALUES ('"+ estadio.Nombre +"','"+ estadio.Localidad +"')"); insert.Execute(); kConnection.Close(); }
public static object getEstadioById(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var estadios = kConnection.Raw("Select * from estadios where id = " + estadio.Id).ToList(); kConnection.Close(); return estadios; }
public static void deleteEstadio(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var data = kConnection.Raw("DELETE FROM [dbo].[estadios] WHERE id = " + estadio.Id); data.Execute(); kConnection.Close(); }
public static bool AssignRobot(Communicator communicator, GeneralTypeRobot robot) { if (robot == null) { throw new ArgumentNullException("robot"); } if (communicator == null) { throw new ArgumentNullException("communicator"); } IPresentationProtocol pp = communicator.GetPresentationProtocol(); if (pp == null) { throw new ArgumentNullException("communicator.GetPresentationProtocol()"); } IDataLink dl = communicator.GetDataLink(); if (dl == null || communicator.GetDataLink().Connected() != true) { throw new InvalidOperationException("Can't assign robot without being connected"); } MessageActionMapper map = new MessageActionMapper(robot); communicator.GetPresentationProtocol().SetReceiver(map); return(true); }
public static void updateEquipo(Equipo equipo, IDataLink kConnection) { kConnection.Open(); var equipoEdit = kConnection.Raw("UPDATE[dbo].[equipos] SET[nombre] = '" + equipo.Nombre + "',[uniforme] = '" + equipo.Uniforme + "' WHERE id = " + equipo.Id); equipoEdit.Execute(); kConnection.Close(); }
public static object getEquipoById(Equipo equipo, IDataLink kConnection) { kConnection.Open(); var equipos = kConnection.Raw("Select * from equipos where id = " + equipo.Id).ToList(); kConnection.Close(); return(equipos); }
public static object getEstadioById(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var estadios = kConnection.Raw("Select * from estadios where id = " + estadio.Id).ToList(); kConnection.Close(); return(estadios); }
public static object getPartidos(IDataLink kConnection) { kConnection.Open(); var partidos = kConnection.Raw("select p.id, e.nombre as equipo1, p.marcador1, e2.nombre as equipo2, p.marcador2, es.nombre as estadio from [keroseneDB].[dbo].[partidos] p inner join[keroseneDB].[dbo].[equipos] e on e.id = p.equipo1 inner join[keroseneDB].[dbo].[equipos] e2 on e2.id = p.equipo2 inner join[keroseneDB].[dbo].[estadios] es on es.id = p.estadio").ToList(); kConnection.Close(); return(partidos); }
public static void deleteEquipo(Equipo equipo, IDataLink kConnection) { kConnection.Open(); var data = kConnection.Raw("DELETE FROM [dbo].[equipos] WHERE id = " + equipo.Id); data.Execute(); kConnection.Close(); }
public static void insertEstadio(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var insert = kConnection.Raw("INSERT INTO [dbo].[estadios] ([nombre], [localidad]) VALUES ('" + estadio.Nombre + "','" + estadio.Localidad + "')"); insert.Execute(); kConnection.Close(); }
public static object getEquipos(IDataLink kConnection) { kConnection.Open(); var equipos = kConnection.Raw("Select * from equipos").ToList(); kConnection.Close(); return(equipos); }
public static void insertEquipo(Equipo equipo, IDataLink kConnection) { kConnection.Open(); var insert = kConnection.Raw("INSERT INTO [dbo].[equipos] ([nombre], [Uniforme]) VALUES ('" + equipo.Nombre + "','" + equipo.Uniforme + "')"); insert.Execute(); kConnection.Close(); }
public static void insertPartido(Partidos partido, IDataLink kConnection) { kConnection.Open(); var insert = kConnection.Raw("INSERT INTO [dbo].[partidos] ([equipo1], [marcador1], [equipo2], [marcador2], [estadio]) VALUES(" + partido.Equipo1 + ", null, " + partido.Equipo2 + ", null, " + partido.Estadio + ")"); insert.Execute(); kConnection.Close(); }
public ILinkReader CreateReader(IDataLink link, string query) { OleDbDataReader reader = new OleDbDataReader(); reader.Initialize(link); reader.Command = query; return(reader); }
public static object getEstadios(IDataLink kConnection) { kConnection.Open(); var estadios = kConnection.Raw("select * from estadios").ToList(); kConnection.Close(); return(estadios); }
public ILinkReader CreateReader(IDataLink link, string query) { // Query is irrevalent - the text file name is in the query string TextReader reader = new TextReader(); reader.Initialize(link); return(reader); }
public void SendData(byte[] data) { IDataLink dataLink = this.innerDataLink; if (dataLink != null) { dataLink.SendData(data); } }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="link">The link this command is associated with.</param> protected Command(IDataLink link) { if (link == null) throw new ArgumentNullException("link", "Link cannot be null."); if (link.IsDisposed) throw new ObjectDisposedException(link.ToString()); _Link = link; _Parameters = _Link.Engine.CreateParameterCollection(); if (_Parameters == null) throw new CannotCreateException( "Cannot create a new collection of parameters for this instance."); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="link">The link this nestable transaction is associated with.</param> /// <param name="mode">The initial transactional mode.</param> protected NestableTransaction( IDataLink link, NestableTransactionMode mode = NestableTransactionMode.Database) { if (link == null) throw new ArgumentNullException("link", "Link cannot be null."); if (link.IsDisposed) throw new ObjectDisposedException(link.ToString()); _Link = link; _Mode = mode; }
/// <summary> /// Create a packet from an array of bytes. /// </summary> /// <param name="data">The bytes of the packet. This array should not be changed after creating the packet until the packet is no longer used.</param> /// <param name="timestamp">A timestamp of the packet - when it was captured.</param> /// <param name="dataLink">The type of the datalink of the packet.</param> /// <param name="originalLength"> /// Length this packet (off wire). /// If the value is less than the data size, it is ignored and the original length is considered to be equal to the data size. /// </param> public Packet(byte[] data, DateTime timestamp, IDataLink dataLink, uint originalLength) { if (data == null) { throw new ArgumentNullException("data"); } _data = data; _timestamp = timestamp; _dataLink = dataLink; OriginalLength = Math.Max((uint)_data.Length, originalLength); }
public static object updatePartido(int id, IDataLink kConnection) { kConnection.Open(); Random random = new Random(); int marcador1 = random.Next(0, 7); int marcador2 = random.Next(0, 7); var partidos = kConnection.Raw("UPDATE [dbo].[partidos] SET[marcador1] = " + marcador1 + ", [marcador2] = " + marcador2 + " WHERE[id] = " + id); partidos.Execute(); kConnection.Close(); return partidos; }
public PresentationBase(IDataLink dataLink) { if (dataLink == null) { throw new InvalidOperationException(); } this.DataLink = dataLink; this.DataLink.OnDataReceive += DataLink_OnDataReceive; this.DataLink.OnCommandReceive += new EventHandler <DataLinkCommandEventArgs>(DataLink_OnCommandReceive); }
public void IncomingMessage(Message newMessage, IDataLink datalink) { Debug.Log(newMessage.stringData); foreach (var shape in newMessage.shapeUpdateInfo.changedShapes) { Debug.Log(shape.id); foreach (var vertex in shape.vertices) { Debug.Log(string.Format("x:{0}, y:{1}, z:{2}", vertex.x, vertex.y, vertex.z)); } } }
public static object updatePartido(int id, IDataLink kConnection) { kConnection.Open(); Random random = new Random(); int marcador1 = random.Next(0, 7); int marcador2 = random.Next(0, 7); var partidos = kConnection.Raw("UPDATE [dbo].[partidos] SET[marcador1] = " + marcador1 + ", [marcador2] = " + marcador2 + " WHERE[id] = " + id); partidos.Execute(); kConnection.Close(); return(partidos); }
/// <summary> /// Creates a packet from a string that represents bytes in a hexadecimal format. /// </summary> public static Packet FromHexadecimalString(string value, DateTime timestamp, IDataLink dataLink) { if (value == null) throw new ArgumentNullException("value"); byte[] bytes = new byte[value.Length / 2]; for (int i = 0; i < value.Length; i += 2) { bytes[i / 2] = Convert.ToByte(value.Substring(i, 2), 16); } return new Packet(bytes, timestamp, dataLink); }
public Communicator(IDataLink dataLink, IPresentationProtocol pP) { if (pP == null) { throw new System.ArgumentException("Parameter cannot be null", "pP"); } if (dataLink == null) { throw new System.ArgumentException("Parameter cannot be null", "dataLink"); } _pp = pP; _datalink = dataLink; }
/// <summary> /// Invoked when disposing or finalizing this instance. /// </summary> /// <param name="disposing">True if the object is being disposed, false otherwise.</param> protected virtual void OnDispose(bool disposing) { if (disposing) { try { if (_Link != null && !_Link.IsDisposed && this.IsActive) Abort(); } catch { } _Link = null; } _IsDisposed = true; }
/// <summary> /// Invoked when disposing or finalizing this instance. /// </summary> /// <param name="disposing">True if the object is being disposed, false otherwise.</param> protected virtual void OnDispose(bool disposing) { if (disposing) { try { if (_Parameters != null && !_Parameters.IsDisposed) _Parameters.Dispose(); } catch { } } _Parameters = null; _Link = null; _IsDisposed = true; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="link">The link this command is associated with.</param> protected CommandEnum(IDataLink link) : base(link) { }
public ILinkWriter CreateWriter(IDataLink link, string table) { throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="link">The link this instance will be associated with.</param> public RawCommand(IDataLink link) : base(link) { }
/// <summary> /// Creates a new repository instance associated with the given link. /// </summary> /// <param name="link">The link reference.</param> /// <returns>The newly created repository.</returns> public static IDataRepository Create(IDataLink link) { return new Concrete.DataRepository(link); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="link">The link this instance will be associated with.</param> /// <param name="table">A dynamic lamnda expression that resolves into the name of the /// table affected by this operation.</param> public InsertCommand(IDataLink link, Func<dynamic, object> table) : base(link) { _TableName = Link.Engine.Parser.Parse(table); _TableName = _TableName.Validated("Table"); }
public void Initialize(IDataLink link) { _link = link; }
public ILinkWriter CreateWriter(IDataLink link, string table) { SqlDataWriter writer = new SqlDataWriter(); writer.Initialize(link); return writer; }
public ILinkReader CreateReader(IDataLink link, string query) { throw new NotImplementedException(); }
public EquiposController() { KeroseneConection kc = new KeroseneConection(); kConnection = kc.Conection(); }
public FakeTransaction(IDataLink link, NestableTransactionMode mode) : base(link, mode) { }
public PartidosController() { KeroseneConection kc = new KeroseneConection(); kConnection = kc.Conection(); }
public void Initialize(IDataLink link) { throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="link">The link this nestable transaction is associated with.</param> /// <param name="mode">The initial transactional mode.</param> public NestableTransaction( IDataLink link, Core.NestableTransactionMode mode = Core.NestableTransactionMode.Database) : base(link, mode) { }
public FakeCommandProvider(IDataLink link) { TheCommand = link.Query(); }