Exemple #1
0
        // Constructor
        public Connector(string AHost, int APort, string AUsername, string APassword)
        {
            TCPClient = new TCP.Client(AHost, APort, AUsername, APassword);

            // Initial Connect to check if connection to server is possible.
            if (!TCPClient.Connect())
            {
                throw new System.InvalidOperationException("Cannot connect to Server");
            }
        }
Exemple #2
0
        public override void Initialize(string file)
        {
            Config.Configuration config = new Config.Configuration(file);
            protocol = (IProtocolParse)ObjectFactory.CreateInstance(config.Type);

            ip = config.IP;
            port = config.Port;

            client = new Client("192.168.10.103", 2000);
            client.OnReceive += new ReceiveEventHandler(client_OnReceive);
            client.Connect();

            //client.Write("9876543210");

            //string s = client.Read();
        }
Exemple #3
0
        // ExecSQL
        public SQLiteResult ExecSQL(string ASQLQuery, Boolean ANoResult = false)
        {
            // Initialize Result
            SQLiteResult Res = new SQLiteResult();

            Res.XML          = new XDocument();
            Res.Error        = true;
            Res.ErrorMessage = "Result set is init value";
            Res.FieldCount   = 0;
            Res.RowCount     = 0;
            Res.Names        = new string[0];
            Res.Type         = new string[0, 0];
            Res.Value        = new string[0, 0];

            // Send Query to TCP-Client
            try
            {
                // SQL Query -> TCP Client
                if (!TCPClient.Connected())
                {
                    if (!TCPClient.Connect())
                    {
                        throw new System.SystemException("Client exception: Cannot connect to Server");
                    }
                }
                string ExecResult = TCPClient.ExecSQL(ASQLQuery, ANoResult);

                // Handle Result
                if (ANoResult)
                {
                    Res.Error        = false;
                    Res.ErrorMessage = "";
                }
                else
                {
                    Res.XML = XDocument.Parse(ExecResult);
                    ParseSQLiteResult(ref Res);
                }
            } catch (Exception e) {
                Res.Error        = true;
                Res.ErrorMessage = "Client Exception1: " + e.Message;
            }

            // Return result
            return(Res);
        }