예제 #1
0
        /// <summary>
        ///  保存一天的CSV文件
        /// </summary>
        /// <param name="Door">门号</param>
        /// <param name="Way">路径</param>
        public static void PaeserveInfo(int Door, string Way)
        {
            string BeginTime = Convert.ToString(DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 00:00:00"));

            string EndTime = Convert.ToString(DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 23:59:59"));

            try
            {
                string    sql = string.Format(@"select * from [dbo.tb_MachineStatus] where [Door] like '%{0}%'and [WriteTime] >= '{1}' and [WriteTime] <= '{2}'", Door, BeginTime, EndTime);
                DataTable dt  = SqlServerHelp.Query(sql).Tables[0];
                //DataTable dt = new DataTable();
                // dt = SqlServerHelp.Query(sql).Tables[0];
                dt.Columns["id"].ColumnName = "ID";

                dt.Columns["WriteTime"].ColumnName = "采集时间";

                dt.Columns["Door"].ColumnName = "门号";

                dt.Columns["UpperLimitOfTemperature"].ColumnName = "上限温度";

                dt.Columns["LowerTemperatureLimit"].ColumnName = "下限温度";

                dt.Columns["SetValueMonitoringTemperature"].ColumnName = "设定温度";

                dt.Columns["MonitoringTemperature"].ColumnName = "监控温度";

                dt.Columns["RunTime"].ColumnName = "运行时间";

                dt.Columns["SetTime"].ColumnName = "设定时间";
                Common.CSVHelper.SaveCSV(dt, Way);//保存CSV文件
            }
            catch (Exception ex) { }
        }
예제 #2
0
        /// <summary>
        /// 报警日志错误查询
        /// </summary>
        /// <param name="LineNumber"></param>
        /// <param name="timeBegin"></param>
        /// <param name="timeEnd"></param>
        /// <returns></returns>
        public static DataTable InquiryError(string LineNumber, string timeBegin, string timeEnd)
        {
            string sql = string.Format(@"select top {0}*from dbo.[dbo.tb_Error]  where [ErrorTime] >= '{1}' and [ErrorTime] <= '{2}'", LineNumber, timeBegin, timeEnd);

            //sql查询语句,注意查询命令不能加 % 号
            //语法and [SyTime] >= '{2}' and [SyTime] <= '{3}'"
            connError = SqlServerHelp.Query(sql).Tables[0];
            return(connError);
        }
예제 #3
0
        /// <summary>
        /// 查询采集温度
        /// </summary>
        /// <param name="Door">门号</param>
        /// <param name="LineNumber">查询行数</param>
        /// <param name="timeBegin">查询开始时间</param>
        /// <param name="timeEnd">查询停止时间</param>
        /// <returns></returns>
        public static DataTable Inquiry(string Door, string LineNumber, string timeBegin, string timeEnd)
        {
            string sql = string.Format(@"select top {0}*from dbo.[dbo.tb_MachineStatus] 
        where [Door] like '%{1}%'and  [WriteTime] >= '{2}'
        and [WriteTime] <= '{3}'", LineNumber, Door, timeBegin, timeEnd);

            //sql查询语句,注意查询命令不能加 % 号
            //语法and [SyTime] >= '{2}' and [SyTime] <= '{3}'"
            conn = SqlServerHelp.Query(sql).Tables[0];
            return(conn);
        }