Ejemplo n.º 1
0
 /// <summary>
 /// 内外部数据转换
 /// </summary>
 /// <param name="info"></param>
 /// <param name="machine"></param>
 /// <returns></returns>
 private MachineReport exchangeData(Machines machine)
 {
     return(new MachineReport()
     {
         DateCreate = DateTime.Now,
         MachineNumber = machine.Number,
         MachineName = machine.Name,
         MachineId = machine.ID,
         RoomId = machine.RoomID,
         RoomNumber = machine.RoomName,
         RoomName = machine.RoomName
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 内外部数据转换
        /// </summary>
        /// <param name="info"></param>
        /// <param name="machine"></param>
        /// <returns></returns>
        private HeartBreak exchangeData(NetStructure.HeartBreak info, Machines machine)
        {
            int    channel     = info.ChannelInfo;
            int    machineId   = machine.ID;
            string machineName = machine.Name;

            return(new HeartBreak()
            {
                DateCreate = DateTime.Now,
                ChannelInfo = channel,
                MachineId = machineId,
                MachineName = machineName
            });
        }
Ejemplo n.º 3
0
        private Machines exchangeMachine(DataRow dr)
        {
            Machines info = new Machines();

            info.ID         = Convert.ToInt32(dr["ID"]);
            info.Number     = dr["Number"].ToString();
            info.Name       = dr["Name"].ToString();
            info.RoomID     = Convert.ToInt32(dr["RoomID"]);
            info.RoomNumber = dr["RoomNumber"].ToString();
            info.RoomName   = dr["RoomName"].ToString();
            info.IpAddress  = dr["IpAddress"].ToString();
            info.RemarkInfo = dr["RemarkInfo"].ToString();
            info.Status     = (enumMachineStatus)Enum.Parse(typeof(enumMachineStatus), dr["Status"].ToString());

            return(info);
        }
Ejemplo n.º 4
0
        public byte[] HandlerClientData(byte[] buff)
        {
            byte[]    buffResp = { 1 };
            DbHandler db       = new DbHandler();

            NetStructure.DeviceMaterial outInfo = this.DecodeData(buff);
            Machines            machine         = db.SelectMachine(outInfo.MachineId);
            Schedules           schedule        = db.SelectSchedule(outInfo.ScheduleNumber);
            MachineCallMaterial innerInfo       = this.exchangeData(machine, schedule);

            //记录原始数据
            db.InsertMachineCallMaterial(innerInfo);

            buffResp[0] = 0;

            return(buffResp);
        }
Ejemplo n.º 5
0
        public void HandlerTest()
        {
            DbHandler db = new DbHandler();

            NetStructure.HeartBreak outInfo = new NetStructure.HeartBreak()
            {
                MachineId   = 19,
                ChannelInfo = 6
            };
            Machines   machine   = db.SelectMachine(outInfo.MachineId);
            HeartBreak innerInfo = this.exchangeData(outInfo, machine);

            //记录原始数据
            db.InsertHeartBreak(innerInfo);
            ////记录设备状态
            //RefreshOnlineInfo(machine);
        }
Ejemplo n.º 6
0
        public byte[] HandlerClientData(byte[] buff)
        {
            byte[]    buffResp    = { 1 };
            DbHandler db          = new DbHandler();
            DateTime  currentTime = DateTime.Now;

            NetStructure.DeviceStartEnd outInfo = this.DecodeData(buff);
            Machines        machine             = db.SelectMachine(outInfo.MachineId);
            Schedules       schedule            = db.SelectSchedule(outInfo.ScheduleNumber);
            UserProfile     userInfo            = db.SelectUser(outInfo.UserNumber);
            MachineStartEnd innerInfo           = this.exchangeData(outInfo, machine, schedule, userInfo);

            //记录原始数据

            if (outInfo.Status == enumDeviceWorkStatus.Start)
            {
                innerInfo.DateStart = currentTime;
                db.InsertMachineStartEnd(innerInfo);
            }
            else
            {
                int startId = db.GetStartEndID(new MachineStartEnd()
                {
                    MachineId       = outInfo.MachineId,
                    SchueduleNumber = outInfo.ScheduleNumber,
                    UserNumber      = outInfo.UserNumber,
                    Status          = enumDeviceWorkStatus.Start
                });
                if (startId == 0)
                {
                    innerInfo.DateEnd = currentTime;
                    db.InsertMachineStartEnd(innerInfo);
                }
                else
                {
                    db.FinishStartStatus(startId);
                }
            }

            buffResp[0] = 0;

            return(buffResp);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 内外部数据转换
 /// </summary>
 /// <param name="info"></param>
 /// <param name="machine"></param>
 /// <returns></returns>
 private MachineCallMaterial exchangeData(Machines machine, Schedules schedule)
 {
     return(new MachineCallMaterial()
     {
         DateCreate = DateTime.Now,
         MachineNumber = machine.Number,
         MachineId = machine.ID,
         MachineName = machine.Name,
         RoomId = machine.RoomID,
         RoomNumber = machine.RoomName,
         RoomName = machine.RoomName,
         OrderId = schedule.OrderId,
         OrderNumber = schedule.OrderNumber,
         ScheduleId = schedule.ID,
         SchueduleNumber = schedule.Number,
         MaterialInfo = schedule.MaterialDetail,
         Status = enumDeviceWarnningStatus.Unhandler
     });
 }
Ejemplo n.º 8
0
        public byte[] HandlerClientData(byte[] buff)
        {
            DbHandler db = new DbHandler();

            NetStructure.HeartBreak outInfo = this.DecodeData(buff);
            Machines machine = db.SelectMachine(outInfo.MachineId);

            if (machine == null)
            {
                throw new Exception(outInfo.MachineId.ToString());
            }
            //记录设备状态
            RefreshOnlineInfo(machine);
            ////记录原始数据
            //HeartBreak innerInfo = this.exchangeData(outInfo, machine);
            //db.InsertHeartBreak(innerInfo);

            byte[] resp = { };
            return(resp);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 内外部数据转换
        /// </summary>
        /// <param name="info"></param>
        /// <param name="machine"></param>
        /// <returns></returns>
        private MachineStartEnd exchangeData(NetStructure.DeviceStartEnd outInfo, Machines machine, Schedules schedule, UserProfile userInfo)
        {
            MachineStartEnd startEndItem = new MachineStartEnd()
            {
                MachineNumber = machine.Number,
                MachineId     = machine.ID,
                MachineName   = machine.Name,
                RoomId        = machine.RoomID,
                RoomNumber    = machine.RoomName
            };

            startEndItem.OrderId         = schedule.OrderId;
            startEndItem.OrderNumber     = schedule.OrderNumber;
            startEndItem.ScheduleId      = schedule.ID;
            startEndItem.SchueduleNumber = schedule.Number;
            startEndItem.UserId          = userInfo == null ? 0 : userInfo.UserId;
            startEndItem.UserNumber      = userInfo == null ? "" : userInfo.UserName;
            startEndItem.Status          = outInfo.Status;

            return(startEndItem);
        }
Ejemplo n.º 10
0
        private void RefreshOnlineInfo(Machines machine)
        {
            const string ONLINE_FACTRORY_ROOM = "ONLINEFACTORYROOM", PRE_ROOM_NAME_NUMBER = "PREROOMNAMENUMBER", PRE_ONLINE_MACHINE = "PREONLINEMACHINE",
                         PRE_MACHINE_NAME_NUMBER = "PREMACHINENAMENUMBER", PRE_ONLINE_TIME = "PREONLINETIME";

            using (ServiceStack.Redis.IRedisClient client = GlobalVariable.RedisClient)
            {
                HashSet <string> roomList = client.GetAllItemsFromSet(ONLINE_FACTRORY_ROOM);
                if (!roomList.Contains(machine.RoomNumber))
                {
                    client.AddItemToSet(ONLINE_FACTRORY_ROOM, machine.RoomNumber);
                    client.Set <string>(PRE_ROOM_NAME_NUMBER + machine.RoomNumber, machine.RoomName);
                }
                string           strMachineValue = PRE_ONLINE_MACHINE + machine.RoomNumber;
                HashSet <string> machineList     = client.GetAllItemsFromSet(strMachineValue);
                if (!machineList.Contains(machine.Number))
                {
                    client.AddItemToSet(strMachineValue, machine.Number);
                    client.Set <string>(PRE_MACHINE_NAME_NUMBER + machine.Number, machine.Name);
                }
                client.Set <long>(PRE_ONLINE_TIME + machine.Number, DateTime.Now.Ticks);
            }
        }