uusing Oracle.ManagedDataAccess.Client;
using System;
using System.Net.Sockets;
using System.Text;
namespace Zadanie1
{
public class Program
{
private const string TCP_HOST = "150.254.11.230";
private const int TCP_PORT = 31084;
private const string ORACLE_CONNECTION_STRING =
"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=150.254.11.231)" +
"(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));" +
"User ID=egzamin2019;Password=student;";
private static Random random
= new Random
();
public static void Main(string[] args)
{
Socket client;
byte[] buffer;
int a, i;
OracleConnection connection;
OracleCommand command;
client
= new Socket
(AddressFamily
.InterNetwork, SocketType
.Stream, ProtocolType
.Tcp);
client.Connect(TCP_HOST, TCP_PORT);
client.Receive(buffer, 4, SocketFlags.None);
a = BitConverter.ToInt32(buffer, 0);
Console.WriteLine("Odebrano A = " + a);
connection
= new OracleConnection
(ORACLE_CONNECTION_STRING
);
connection.Open();
for (i = 0; i < a; i++)
{
client.Receive(buffer);
Console.Write("Odebrano = ");
PrintOutByteArray(buffer);
command
= new OracleCommand
();
command.Connection = connection;
command.CommandText = string.Format(
"INSERT INTO grupaA (ID, indeks, student) VALUES ({0}, 131084, '{1}')",
random.Next(1, 1000), Encoding.UTF8.GetString(buffer));
command.ExecuteNonQuery();
Console.WriteLine("Wykonano instrukcję SQL = " + command.CommandText);
}
connection.Close();
client.Close();
}
private static void PrintOutByteArray(byte[] buffer)
{
int i;
for (i = 0; i < buffer.Length; i++)
{
Console.Write(buffer[i]);
}
Console.WriteLine();
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}