Exemple #1
0
        public byte[] HandlerClientData(byte[] buff)
        {
            byte[]    buffResp = { 1 };
            DbHandler db       = new DbHandler();

            try
            {
                int           outInfo   = this.DecodeData(buff);
                Machines      machine   = db.SelectMachine(outInfo);
                MachineReport innerInfo = this.exchangeData(machine);
                //记录原始数据
                db.InsertMachineReport(innerInfo);
                //调用外部接口
                string reportNumber = db.GetRoomReportNumber(machine.RoomID);
                Dictionary <string, string> tempParam = new Dictionary <string, string>()
                {
                    { "code", machine.Number }, { "adminname", reportNumber }
                };
                string strInfo = WebInfo.PostPageInfo(EXTERNAL_URL, tempParam);
                if (!strInfo.Contains("成功"))
                {
                    db.InsertErrorInfo(enumSystemErrorCode.DeviceReportOutInterface, null, string.Format("{0}:{1}", reportNumber, machine.Number), null);
                }

                buffResp[0] = 0;
            }
            catch
            {
            }
            return(buffResp);
        }
Exemple #2
0
        public void InsertMachineReport(MachineReport info)
        {
            string strSql = @"INSERT INTO MachineReports (DateCreate,MachineId,MachineName,MachineNumber,RoomId,RoomNumber,RoomName,[Status]) 
                              VALUES (@DateCreate,@MachineId,@MachineName,@MachineNumber,@RoomId,@RoomNumber,@RoomName,@Status)";

            using (SqlCommand cmd = new SqlCommand(strSql, conn))
            {
                cmd.Parameters.AddWithValue("@DateCreate", info.DateCreate);
                cmd.Parameters.AddWithValue("@MachineId", info.MachineId);
                cmd.Parameters.AddWithValue("@MachineNumber", info.MachineNumber);
                cmd.Parameters.AddWithValue("@MachineName", info.MachineName);
                cmd.Parameters.AddWithValue("@RoomId", info.RoomId);
                cmd.Parameters.AddWithValue("@RoomNumber", info.RoomNumber);
                cmd.Parameters.AddWithValue("@RoomName", info.RoomName);
                cmd.Parameters.AddWithValue("@Status", info.Status);

                cmd.ExecuteNonQuery();
            }
        }