Beispiel #1
0
        void ExecuteAllTask()
        {
            if (System.Diagnostics.Process.GetProcessesByName(ClientConfiguration.Instance.ProcessName).Length > 1)
            {
                grabPerformer_OutputInfo("化验进程正在运行,暂停上传");
                return;
            }
            DataTable dtl = new DataTable();

            switch (ClientConfiguration.Instance.DbType.ToLower())
            {
            case "access":
                dtl = new CMCS.DapperDber.Dbs.AccessDb.AccessDapperDber(ClientConfiguration.Instance.ConnStr).ExecuteDataTable(ClientConfiguration.Instance.SQL);
                break;

            case "sqlserver":
                dtl = new CMCS.DapperDber.Dbs.SqlServerDb.SqlServerDapperDber(ClientConfiguration.Instance.ConnStr).ExecuteDataTable(ClientConfiguration.Instance.SQL);
                break;

            case "sqlite":
                dtl = new CMCS.DapperDber.Dbs.SQLiteDb.SQLiteDapperDber(ClientConfiguration.Instance.ConnStr).ExecuteDataTable(ClientConfiguration.Instance.SQL);
                break;
            }
            UdpClient   udpClient   = new UdpClient();
            IPEndPoint  serverPoint = new IPEndPoint(IPAddress.Parse(ClientConfiguration.Instance.ServerIp), ClientConfiguration.Instance.ServerPort);
            SendMessage sendMessage = new SendMessage();

            sendMessage.UpLoadIdentifier = ClientConfiguration.Instance.UpLoadIdentifier;
            sendMessage.DataColumns      = CMCS.CommonADGS.Core.OracleSqlBuilder.ColumnToColumnList(dtl.Columns);

            byte[] sendByte = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(sendMessage));
            udpClient.Send(sendByte, sendByte.Length, serverPoint);
            grabPerformer_OutputInfo("数据库结构发送成功");
            int res = 0;

            foreach (DataRow item in dtl.Rows)
            {
                sendMessage = new SendMessage();
                sendMessage.UpLoadIdentifier = ClientConfiguration.Instance.UpLoadIdentifier;
                sendMessage.DataRows         = CMCS.CommonADGS.Core.OracleSqlBuilder.ColumnToColumnList(item);

                sendByte = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(sendMessage));
                udpClient.Send(sendByte, sendByte.Length, serverPoint);
                Thread.Sleep(10);
                res++;
            }
            grabPerformer_OutputInfo(string.Format("发送{0}条数据", res));
        }
Beispiel #2
0
        public override System.Data.DataTable ExecuteGrab()
        {
            DataTable dtl = new DataTable();

            switch (DbType.ToLower())
            {
            case "access":
                dtl = new CMCS.DapperDber.Dbs.AccessDb.AccessDapperDber(ConnStr).ExecuteDataTable(SQL);
                break;

            case "sqlserver":
                dtl = new CMCS.DapperDber.Dbs.SqlServerDb.SqlServerDapperDber(ConnStr).ExecuteDataTable(SQL);
                break;

            case "sqlite":
                dtl = new CMCS.DapperDber.Dbs.SQLiteDb.SQLiteDapperDber(ConnStr).ExecuteDataTable(SQL);
                break;
            }

            return(dtl);
        }