/// <summary>
        /// 查询进出记录
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public List <EnterOutLogInfo> QueryEnterOugLogs(string cardNo, DateTime date)
        {
            //TODO:查询当天的进出记录
            DateTime beginDate = DateTime.Parse(date.AddDays(-2).ToShortDateString() + " 0:0:0");
            DateTime endDate   = DateTime.Parse(date.ToShortDateString() + " 23:59:59");
            List <EnterOutLogInfo>        enterOutLogs     = T_SM_EnterOutLog.GetEnterOutLogs(cardNo, null, null, beginDate, endDate);
            IEnumerable <EnterOutLogInfo> query            = from items in enterOutLogs orderby items.EnterOutTime select items;
            List <EnterOutLogInfo>        enterOutLogsSort = new List <EnterOutLogInfo>();

            foreach (var info in query)
            {
                enterOutLogsSort.Add(info);
            }
            return(enterOutLogsSort);
        }
Пример #2
0
        public string StuInOutLog(string StuNo, string StartDate, string EndDate)
        {
            try
            {
                if (!Verifylicensing())
                {
                    return("非法操作,此接口未进行授权!");
                }
                List <EnterOutLogInfo> list = T_SM_EnterOutLog.GetEnterOutLogs(StuNo, null, null, DateTime.Parse(StartDate), DateTime.Parse(EndDate));
                //TODO:转换成xml结构的算法
                //创建一个xml对象
                XmlDocument xmlDoc = new XmlDocument();
                //创建开头
                XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                xmlDoc.AppendChild(dec);
                //创建根节点
                XmlElement root = xmlDoc.CreateElement("StuInOutLog");
                xmlDoc.AppendChild(root);

                for (int i = 0; i < list.Count; i++)
                {
                    XmlElement logNode  = xmlDoc.CreateElement("Log");
                    string     seatNo   = list[i].SeatNo;
                    string     roomName = list[i].ReadingRoomName;
                    string     message  = list[i].Remark;
                    string     time     = list[i].EnterOutTime.ToString();
                    logNode.SetAttribute("SeatNo", seatNo);
                    logNode.SetAttribute("RoomName", roomName);
                    logNode.SetAttribute("DateTime", time);
                    logNode.SetAttribute("Describe", message);
                    root.AppendChild(logNode);
                }
                return(xmlDoc.OuterXml);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }