예제 #1
0
        /// <summary>
        /// 环境事件记录
        /// </summary>
        public void NewEnvirEventRecord(EventType type, string area, DeviceRunModel reason, string content)
        {
            string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string strSql  = "insert into tb_EnviriEvent (Type,Area,Reason,EventContent,Time)values " +
                             "('" + type.ToString() + "','" + area + "','" + reason.ToString() + "'," +
                             "'" + content + "','" + strTime + "')";

            datalogic.SqlComNonQuery(strSql);
        }
예제 #2
0
        /// <summary>
        /// 更新和记录 继电器 控制设备 运行或关闭
        /// </summary>
        public void DeviceNewAndRecord(int iRoomIndex, EventType eventType, DeviceRunState onOrOff, DeviceRunModel handOrAuto, bool blRecord)
        {
            EventContent eventContent = EventContent.开启;

            if (onOrOff == DeviceRunState.运行)
            {
                eventContent = EventContent.开启;
                if (eventType == EventType.烘干)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.State = DeviceRunState.运行;
                    }
                }
                else if (eventType == EventType.除湿)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.State = DeviceRunState.运行;
                    }
                }
                else if (eventType == EventType.新风)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.State = DeviceRunState.运行;
                    }
                }
            }
            else if (onOrOff == DeviceRunState.停止)
            {
                eventContent = EventContent.关闭;
                if (eventType == EventType.烘干)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.State = DeviceRunState.停止;
                    }
                }
                else if (eventType == EventType.除湿)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.State = DeviceRunState.停止;
                    }
                }
                else if (eventType == EventType.新风)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.State = DeviceRunState.停止;
                    }
                }
            }
            if (handOrAuto == DeviceRunModel.手动)
            {
                if (eventType == EventType.烘干)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.HandOrAuto = DeviceRunModel.手动;
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.TimeHand   = DateTime.Now;
                    }
                }
                else if (eventType == EventType.除湿)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.HandOrAuto = DeviceRunModel.手动;
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.TimeHand   = DateTime.Now;
                    }
                }
                else if (eventType == EventType.新风)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.HandOrAuto = DeviceRunModel.手动;
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.TimeHand   = DateTime.Now;
                    }
                }
            }
            if (blRecord)
            {
                string strSql = "insert into tb_EnviriEvent (Type,Area,Reason,EventContent,Time)values " +
                                "('" + eventType.ToString() + "','" + clsEnvirControl.listRoom[iRoomIndex].StrName + "','" + handOrAuto.ToString() + "'," +
                                "'" + eventContent.ToString() + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                datalogic.SqlComNonQuery(strSql);

                //if (NewEventShowEvent != null)
                //{
                //    string strPoint = strArea;
                //    if (blMoreAir)
                //        strPoint += btAddr.ToString();
                //    if (content == EventContent.设置温度)
                //    {
                //        NewEventShowEvent(new NewEventEventArgs(EventType.空调, strPoint, content.ToString() + btSetTemp.ToString(), "", ""));
                //    }
                //    else
                //    {
                //        NewEventShowEvent(new NewEventEventArgs(EventType.空调, strPoint, content.ToString(), "", ""));
                //    }
                //}
            }
        }