/// <summary> /// 取得特巡点检详细信息 /// </summary> /// <param name="source"></param> /// <param name="header"></param> /// <returns></returns> private static List <PatrolReportDetail> getDetailList(ReqUploadPatrolInformation source, PatrolReportHeader header, String dirName) { List <PatrolReportDetail> list = new List <PatrolReportDetail>(); if (source != null && source.check_list != null && source.check_list.Count > 0 && header != null) { for (int i = 0; i < source.check_list.Count; i++) { PicInfo item = source.check_list[i]; PatrolReportDetail instance = new PatrolReportDetail(); //前端获取 instance.IsImportant = item.is_important; instance.LocationCode = item.location_code; instance.SpotCode = item.spot_code; instance.Status = item.spot_status_code; instance.Remarks = item.part_remarks; instance.QuestionLevel = item.level_code; instance.PicUrl = dirName + "/" + item.pic_url; Console.WriteLine(instance.PicUrl); //自动设置 instance.PatrolNO = header.PatrolNO; instance.SubNO = i; instance.IsSelected = "0"; //加入列表 list.Add(instance); } } return(list); }
public void getLoadPicByHostIp() { login(); DataLayerResult result = dataLayer.GetLoadPicByHostIp("127.0.0.1"); Assert.AreEqual(result, DataLayerResult.Success); PicInfo info = dataLayer.PicInfoMap["127.0.0.1"]; Assert.IsNotNull(info); Assert.IsNotNull(info.DayLoadAveragePic); Assert.IsNotNull(info.MonthLoadAveragePic); Assert.IsNotNull(info.YearLoadAveragePic); Assert.AreEqual(info.HostIp, "127.0.0.1"); string dayFileName = @"D:\dayfile" + "." + info.FileType; string monthFileName = @"D:\monthfile" + "." + info.FileType; string yearFileName = @"D:\yearfile" + "." + info.FileType; Image dayImage = info.getDayLoadAverageImage(); dayImage.Save(dayFileName); Image monthImage = info.getMonthLoadAverageImage(); monthImage.Save(monthFileName); Image yearImage = info.getYearLoadAverageImage(); yearImage.Save(yearFileName); logou(); }
public void setPicTransactionPage() { PicTransationPath PicTransation = new PicTransationPath(); if (PicTransation.lstPicPath.Count <= 0) { return; } foreach (string strTemp in PicTransation.lstPicPath) { PicTransationControl newPage = new PicTransationControl(); PicInfo PicTempInfo = new PicInfo(); PicTempInfo.nHeight = 780; PicTempInfo.nWidth = 1038; PicTempInfo.strImgLink = strTemp; newPage.DataContext = PicTempInfo; myPicTransationPageQueue.Enqueue(newPage); currentPage = newPage; } //pageTransitionControl.ShowPage(currentPage); getThePicChangeTime(); creatThePicChangeThread(); }
private void PicTransationControl_Loaded(object sender, RoutedEventArgs e) { PicInfo pData = (PicInfo)this.DataContext; //this.Width = pData.nWidth; //this.Height = pData.nHeight; ImgLink.Source = new BitmapImage(new Uri(pData.strImgLink)); }
public DataLayerResult DoResponse(IDataLayer dataLayer, Object response) { GetLoadPicByHostIpResponse res = (GetLoadPicByHostIpResponse)response; if (!string.IsNullOrEmpty(res.hostIp) && !string.IsNullOrEmpty(res.fileType) && res.dayLoadAveragePic != null && res.monthLoadAveragePic != null && res.yearLoadAveragePic != null) { dataLayer.PicInfoMap.Remove(res.hostIp); PicInfo picInfo = new PicInfo(); picInfo.HostIp = res.hostIp; picInfo.FileType = res.fileType; picInfo.DayLoadAveragePic = res.dayLoadAveragePic; picInfo.MonthLoadAveragePic = res.monthLoadAveragePic; picInfo.YearLoadAveragePic = res.yearLoadAveragePic; dataLayer.PicInfoMap.Add(res.hostIp, picInfo); } return(DataLayerResult.Success); }
///<summary> ///添加一张图片 ///</summary> public bool AddPic(PicInfo _PicInfo) { String Sql = "insert into PicInfo(PicName,PicPath,Introduction,UploadTime) values(@PicName,@PicPath,@Introduction,@UploadTime)"; SqlParameter[] Paras = new SqlParameter[] { new SqlParameter("@PicName", _PicInfo.PictureName), new SqlParameter("@PicPath", _PicInfo.PicPath), new SqlParameter("@Introduction", _PicInfo.Introduction), new SqlParameter("@UploadTime", _PicInfo.UpLoadTime) }; if (SqlHelper.ExecuteNonQuery(Sql, Paras, CommandType.Text) > 0) { return(true); } return(false); }
/// <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; } }
public object Save([FromBody] PicInfo picInfo) { try { EFHelper <PicInfo> eFHelper = new EFHelper <PicInfo>(); picInfo.CreateTime = DateTime.Now.ToString("yyyy-dd-MM HH:hh:ss"); eFHelper.Add(picInfo); return(new NewErrorModel() { error = new Error(0, "保存成功!", "") { }, }); } catch (Exception ex) { throw ex; } }
public object Modify(PicInfo picInfo) { try { EFHelper <PicInfo> eFHelper = new EFHelper <PicInfo>(); picInfo.LastModifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int count = eFHelper.Modify(picInfo); return(new NewErrorModel() { count = count, error = new Error(0, "修改成功!", "") { }, }); } catch (Exception ex) { throw ex; } }
//任务2,不断读取Redis节点信息存储并匹配吊弦图像 private void TaskMatchImg() { ImgSaveNode imgNode; CallInfo?.Invoke($"T#读取吊弦数据!\n"); //直到有值为止 while (queImgInfo.Count == 0) { Thread.Sleep(3000);//休眠3秒 } lock (obj) { imgNode = queImgInfo.Dequeue(); CallInfo?.Invoke($"T#匹配杆号:{imgNode.sKM_Pole}\n"); } while (_taskRunning) { //获取数据起始下标--防止redis数据库崩溃 bool redisConn = false; while (!redisConn) { try { if (RedisHelper.IsConnect) { if (!RedisHelper.ReConnect()) { Thread.Sleep(1000);//休息1秒重试 continue; } } string lsImgInd = TYData.StringGet("LstImgInd"); if (string.IsNullOrEmpty(lsImgInd)) { _iImgInd = 0; } _iImgInd = long.Parse(lsImgInd); redisConn = true; } catch (Exception) { _iImgInd = 0; redisConn = false; } } if (queImgInfo.Count < 3) { Thread.Sleep(1000);//防止redis数据写的太慢来不及匹配 } string[] imgKeys = imgInfoDB.ListRange("list", _iImgInd, _iImgInd + m_iSaveImgNumByOnce); for (int i = 0; i < imgKeys.Length; ++i) { string imgKey = imgKeys[i]; string sJson = imgInfoDB.StringGet(imgKey); if (string.IsNullOrEmpty(sJson)) { continue; } //考虑一种情况,redis数据库崩溃了 丢失了很多图像, 中间很多定位信息无用直接跳过 //t: 132430543471152878 min 132430663964619500 max PicInfo picInfo = JsonHelper.GetModel <PicInfo>(sJson); Int64 imgTimeStamp = picInfo.UTC;//ConvertUTC(imgKey); //说明redis中的图像 比 当前MongoDB数据早,扔掉 if (imgTimeStamp < imgNode.minImgTimeStamp) { continue; }//min<imgTimeStamp<max else if (imgTimeStamp < imgNode.maxImgTimeStamp) { imgNode.lstImgId.Add(imgKey);//添加到列表中 //获取图像数据 并存储 byte[] imgData = imgDB.GetByte(imgKey); //PATH+ 战区 \ 公里标_杆号\ 时间_k公里标_杆号_区域编号_相机编号 115600414_K5778_Z2-25_6_13 string imgFullPath = Path.Combine(TaskPath, imgNode.StationName); // \ 公里标_杆号\ imgFullPath = Path.Combine(imgFullPath, "K" + imgNode.sKM_Pole); FileHelper.CreateDir(imgFullPath);//如果不存在则创建当前文件夹 string cid = FileHelper.iTos(picInfo.CID); string imgName = GetImgName(imgKey, cid, imgNode.sKM_Pole); //MessageBox.Show(imgFullPath); bool flag = FileHelper.ImgToFile(Path.Combine(imgFullPath, imgName), imgData); if (flag) { //成功存储 进行计数 ++_iTotalSaveNum; CallInfo?.Invoke($"T#杆号:{imgNode.sKM_Pole} -- 共存储:{_iTotalSaveNum}条\n"); } } else { //当前图像信息时间戳>杆号记录点时间戳 垮杆了则重新获取imgTimeStamp>=imgNode.maxImgTimeStamp while (queImgInfo.Count == 0) { //若队列里面没有数据//休眠5秒 Thread.Sleep(5000); } string sjsonSaveNode = JsonHelper.GetJson(imgNode); WriteTaskInfo(imgNode.sKM_Pole, sjsonSaveNode); //存储 lock (obj) { imgNode = queImgInfo.Dequeue(); //直到有值为止 CallInfo?.Invoke($"T#匹配杆号:{imgNode.sKM_Pole}\n"); } --i; } } if (imgKeys.Length == 0) { Thread.Sleep(10000);//若没有图像获取到休眠10秒 } else { _iImgInd += imgKeys.Length; // LogRecord();//日志数据记录 //记录读取图像列表的下标 WriteTaskInfo("LstImgInd", _iImgInd.ToString()); //记录存储的图像总数量 WriteTaskInfo("saveImgNum", _iTotalSaveNum.ToString()); } } }
protected void btAdd_Click(object sender, EventArgs e) { int MallID = int.Parse(Request.QueryString["MallID"].ToString()); int CityID = int.Parse(Request.QueryString["CityID"].ToString()); try { string imgUrl = ""; if (this.txtImgUrl.FileName.Trim() != "") { _UpLoadFile.FilePath = @"..\..\..\UpLoadPics\"; _UpLoadFile.HtmlKey = "txtImgUrl"; HttpFileCollection updFiles = HttpContext.Current.Request.Files; string PictureName = this.txtPicName.Text.ToString(); _UpLoadFile.ExecUploadFile(updFiles);//执行上传 ArrayList fileArr = (ArrayList)_UpLoadFile.Result[0]; if (fileArr[0].ToString() == "1") { return; } if (fileArr[0].ToString() == "2") { Response.Write("<script language='javascript'>"); Response.Write("alert('图片重名!');"); Response.Write("</script>"); return; } if (fileArr[0].ToString() == "3") { Response.Write("<script language='javascript'>"); Response.Write("alert('图片格式不正确!');"); Response.Write("</script>"); return; } else { imgUrl = fileArr[0].ToString(); PicInfoBLL _PicInfoBLL = new PicInfoBLL(); //根据市ID向图片表中插入一张图片 PicInfo _PicInfo = new PicInfo(); _PicInfo.PictureName = this.txtPicName.Text.Trim(); _PicInfo.PicPath = imgUrl; _PicInfo.Introduction = ""; _PicInfo.UpLoadTime = DateTime.Now; if (_PicInfoBLL.AddPic(_PicInfo)) { int PicID = _PicInfoBLL.GetPicID(this.txtPicName.Text.Trim(), _PicInfo.UpLoadTime); //根据市ID向市图片表中插入一张图片 if (_PicInfoBLL.AddMallPic(MallID, PicID)) { Response.Write("<script language='javascript'>"); //"CityInfoDel.aspx?CityID=" + delWitch; Response.Write("alert('图片添加成功');"); Response.Write("document.location.href='MallPicList.aspx?MallID=" + MallID.ToString() + "&CityID=" + CityID.ToString() + "'"); Response.Write("</script>"); } } } } } catch (Exception ex) { Response.Write("<script language='javascript'>"); Response.Write("alert('添加失败!');"); Response.Write("document.location.href='EntertainmentList.aspx?MallID=" + MallID.ToString() + "&CityID" + CityID.ToString() + "'"); Response.Write("</script>"); } }
///<summary> ///添加一张图片 ///</summary> public bool AddPic(PicInfo _PicInfo) { return(this._PicInfoDAL.AddPic(_PicInfo)); }