예제 #1
0
        /// <summary>
        /// Method to get history pictures information
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="fromTime">fromTime</param>
        /// <param name="toTime">toTime</param>
        /// <param name="picModels">picModels</param>
        public List <PicInfo> GetHisPictures(int lscId, DateTime fromTime, DateTime toTime, string[] picModels)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@LscID",     SqlDbType.Int),
                                         new SqlParameter("@FromTime",  SqlDbType.DateTime),
                                         new SqlParameter("@ToTime",    SqlDbType.DateTime),
                                         new SqlParameter("@PicModels", SqlDbType.NVarChar, 1024) };
                parms[0].Value = lscId;
                parms[1].Value = fromTime;
                parms[2].Value = toTime;
                if (picModels != null && picModels.Length > 0)
                {
                    for (int i = 0; i < picModels.Length; i++)
                    {
                        picModels[i] = String.Format("\"{0}\"", picModels[i]);
                    }
                    parms[3].Value = String.Join(",", picModels);
                }
                else
                {
                    parms[3].Value = DBNull.Value;
                }

                var pics = new List <PicInfo>();
                using (var rdr = SqlHelper.ExecuteReader(SqlHelper.HisConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_REPORT_GETHISPICTURES, parms)) {
                    var id = 0;
                    while (rdr.Read())
                    {
                        var pic = new PicInfo();
                        pic.LscID    = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                        pic.LscName  = ComUtility.DefaultString;
                        pic.RtuID    = ComUtility.DBNullInt32Handler(rdr["RtuID"]);
                        pic.PicID    = ++id;
                        pic.PicName  = ComUtility.DefaultString;
                        pic.PicModel = ComUtility.DBNullStringHandler(rdr["PicModel"]);
                        pic.PicBytes = ComUtility.DBNullBytesHandler(rdr["PicBytes"]);
                        pic.PicTime  = ComUtility.DBNullDateTimeHandler(rdr["PicTime"]);
                        pics.Add(pic);
                    }
                }
                return(pics);
            } catch { throw; }
        }