public string GrabPictureData(string saveFileName, bool needSave = true) { if (!IsPlayStarted()) { return(""); } try { Image img = ocx_VodSdk_GrabPictureData(); if (img == null) { DevComponents.DotNetBar.MessageBoxEx.Show("抓图失败", Framework.Environment.PROGRAM_NAME); return(""); } string time = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string type = "视频截图"; string fileName = VideoName.Replace(".", "_").Replace(":", "_") + type + time + ".jpg"; //fileName = Framework.Environment.PictureSavePath.TrimEnd('\\') + "\\" + fileName; if (!string.IsNullOrEmpty(saveFileName)) { fileName = saveFileName; } else { System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.RestoreDirectory = true; sfd.Filter = "图片文件|*.jpg;*.bmp;*.png|全部文件|*.*"; sfd.FileName = fileName; sfd.InitialDirectory = Framework.Environment.PictureSavePath; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = sfd.FileName; } else { needSave = false; } } if (needSave) { img.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); img.Dispose(); return(fileName); } return(""); } catch (SDKCallException ex) { MyLog4Net.Container.Instance.Log.DebugFormat("GrabPictureData error:" + ex); return(""); } }
public void InsertIntoVideos() { string query = string.Format("Insert into Videos(VideoName, Image, DateUploaded, UserName) values ('{0}','{1}','{2}','{3}');", VideoName.Replace("'", "''"), Image, DateUploaded, UserName); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["VideoConnectionString"].ToString()); SqlCommand com = new SqlCommand(query, con); try { con.Open(); Convert.ToInt32(com.ExecuteScalar()); } finally { con.Close(); } }