Esempio n. 1
0
 // POST: Admin/Video/Sua
 public ActionResult Sua(VIDEO vdo)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         VIDEO video = db.VIDEOs.SingleOrDefault(n => n.IdVideo == vdo.IdVideo);
         if (video != null)
         {
             video.TenVideo  = vdo.TenVideo;
             video.LinkVideo = vdo.LinkVideo;
             if (vdo.NgayDang == null)
             {
                 video.NgayDang = video.NgayDang;
             }
             else
             {
                 video.NgayDang = vdo.NgayDang;
             }
             video.IdAlbum      = vdo.IdAlbum;
             ViewBag.IdAlbum    = new SelectList(db.ALBUMs.ToList(), "IdAlbum", "TenAlbum", video.IdAlbum);
             ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
             video.IdTaiKhoan   = vdo.IdTaiKhoan;
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.QueryString["DOC_ID"]))
                {
                    string  document_id = Request.QueryString["DOC_ID"];
                    decimal doc_id      = decimal.Parse(document_id);
                    VIDEO   v           = MediaVideoMgr.SelectVideoById(doc_id);

                    List <SETTINGS> sets               = SQMSettings.SelectSettingsGroup("MEDIA_UPLOAD", "");
                    string          storageContainer   = sets.Find(x => x.SETTING_CD == "STORAGE_CONTAINER").VALUE.ToString();
                    string          storageURL         = sets.Find(x => x.SETTING_CD == "STORAGE_URL").VALUE.ToString();
                    string          storageQueryString = sets.Find(x => x.SETTING_CD == "STORAGE_QUERY").VALUE.ToString();

                    int    index    = v.FILE_NAME.ToString().IndexOf(".");
                    string fileType = v.FILE_NAME.Substring(index);
                    string videoSrc = storageURL + storageContainer + "/" + v.VIDEO_ID.ToString() + fileType + storageQueryString;
                    srcControl.Attributes.Add("src", videoSrc);

                    if (fileType.ToLower().Equals(".mp4"))
                    {
                        srcControl.Attributes.Add("type", "video/mp4");
                    }
                }
            }
            catch (Exception ex)
            {
                //
                Response.Write("Unable to stream video: " + ex.Message.ToString()); Response.End();
            }
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            VIDEO vIDEO = db.VIDEO.Find(id);

            db.VIDEO.Remove(vIDEO);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 private void GetVieo(VIDEO video)
 {
     st.Children.Clear();
     videoplay.SetVideo(video);
     st.Children.Add(videoplay);
     filminfo.SetInfo(video);
     st.Children.Add(filminfo);
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string name     = "";
            string fileType = "";

            hfChangeUpdate.Value = "0";

            if (string.IsNullOrEmpty(tbTitle.Text.Trim()) || string.IsNullOrEmpty(tbFileDescription.Text.Trim()) || raUpload.UploadedFiles.Count == 0)
            {
                pnlAttachMsg.Visible = true;
                lblAttachMsg.Text    = Resources.LocalizedText.RequiredFieldsMustBeCompleted;
                return;
            }

            uclProgress.BindProgressDisplay(100, "Save uploaded video... ");
            uclProgress.UpdateDisplay(1, 40, "Save uploaded video...");

            int i = 0;

            //if (flFileUpload.HasFile)
            foreach (UploadedFile file in raUpload.UploadedFiles)             // there should only be 1
            {
                uclProgress.UpdateDisplay(1, 50 + (i * 10), "Save uploaded video...");
                //name = flFileUpload.FileName;
                name     = file.FileName;
                fileType = file.GetExtension();

                VIDEO video = MediaVideoMgr.Add(file.FileName, fileType, tbFileDescription.Text.ToString(), tbTitle.Text.ToString(), _recordType, _recordId, _recordStep, ddlInjuryType.SelectedValue.ToString(), rdlBodyPart.SelectedValue.ToString(), ddlVideoType.SelectedValue.ToString(), (DateTime)dmFromDate.SelectedDate, SourceDate, file.InputStream, _plantId);

                pnlAttachMsg.Visible = false;
                pnlListVideo.Visible = false;

                uclProgress.ProgressComplete();

                if (video != null)
                {
                    //string script = string.Format("alert('{0}');", Resources.LocalizedText.SaveSuccess);
                    //ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", script, true);
                    lblAttachMsg.Text    = Resources.LocalizedText.SaveSuccess;
                    pnlAttachMsg.Visible = true;
                    if (AttachmentEvent != null)
                    {
                        SessionManager.ReturnRecordID = video.VIDEO_ID;
                        SessionManager.ReturnObject   = "DisplayVideos";
                        SessionManager.ReturnStatus   = true;
                        AttachmentEvent("save");
                    }
                    else
                    {
                        GetUploadedFiles();
                        tbTitle.Text = tbFileDescription.Text = "";
                    }
                }
            }
        }
Esempio n. 6
0
        // GET: Video/ChiTiet
        public ActionResult ChiTiet(int id = 0)
        {
            VIDEO video = db.VIDEOs.SingleOrDefault(n => n.IdVideo == id);

            if (video == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(video));
        }
Esempio n. 7
0
 public void SetInfo(VIDEO video)
 {
     //filminfo = video;
     //DataContext = filminfo;
     txtten.Text      = video.TenVideo;
     txtquocgia.Text  = video.QuocGia;
     txtdaodien.Text  = video.DaoDien;
     txttomtat.Text   = video.TomTat;
     txtluotxem.Text  = video.LuotXem.ToString();
     imgposter.Source = new BitmapImage(new Uri(video.LinkPoster));
 }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "id_video,titulo,fechaPublicacion,formato,duracion,categoria")] VIDEO vIDEO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vIDEO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.categoria = new SelectList(db.CATEGORIA, "id_categoria", "nombre", vIDEO.categoria);
     return(View(vIDEO));
 }
Esempio n. 9
0
 // POST: Admin/Video/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         VIDEO vdo = db.VIDEOs.SingleOrDefault(n => n.IdVideo == id);
         if (vdo != null)
         {
             db.VIDEOs.Remove(vdo);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //SessionManager.DocumentContext = new SQM.Shared.DocumentScope().CreateNew(1, "", staticScope.RecordType, "", staticScope.RecordID, staticScope.RecordStep, new decimal[0] {});
            //SessionManager.DocumentContext.RecordType = staticScope.RecordType;
            //SessionManager.DocumentContext.RecordID = staticScope.RecordID;
            //SessionManager.DocumentContext.RecordStep = staticScope.RecordStep;
            //uclUpload.SaveFiles();

            if (dmFromDate.SelectedDate == null || dmFromDate.SelectedDate > dmFromDate.MaxDate || raUpload.UploadedFiles.Count == 0)
            {
                dmFromDate.SelectedDate = DateTime.Today;
                //string script = "function f(){OpenManageVideosWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
                // probably should have some error messaging here...
                return;
            }

            string name     = "";
            string fileType = "";
            //raUpload.TargetFolder = "~/Videos/";

            int i = 0;

            //if (flFileUpload.HasFile)
            foreach (UploadedFile file in raUpload.UploadedFiles)             // there should only be 1
            {
                //uclProgress.UpdateDisplay(1, 50 + (i * 10), "Save uploaded video...");
                //name = flFileUpload.FileName;
                name     = file.FileName;
                fileType = file.GetExtension();
                // check to see if this is a video?

                //Stream stream = flFileUpload.FileContent;
                //Stream stream = file.InputStream;

                VIDEO video = MediaVideoMgr.Add(file.FileName, fileType, rtbFileDescription.Text.ToString(), rtbTitle.Text.ToString(), _recordType, _recordId, _recordStep, rddlInjuryType.SelectedValue.ToString(), rdlBodyPart.SelectedValue.ToString(), rddlVideoType.SelectedValue.ToString(), (DateTime)dmFromDate.SelectedDate, SourceDate, file.InputStream, _plantId);

                //uclProgress.ProgressComplete();

                pnlListVideo.Visible          = false;
                pnlAddVideos.Visible          = false;
                SessionManager.ReturnRecordID = video.VIDEO_ID;
                SessionManager.ReturnObject   = "AddVideo";
                SessionManager.ReturnStatus   = true;

                if (AttachmentEvent != null)
                {
                    AttachmentEvent("save");
                }
            }
        }
Esempio n. 11
0
        // GET: VIDEOs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VIDEO vIDEO = db.VIDEO.Find(id);

            if (vIDEO == null)
            {
                return(HttpNotFound());
            }
            return(View(vIDEO));
        }
        protected void Save(bool shouldReturn)
        {
            VIDEO   theVideo = null;
            decimal videoId  = 0;
            string  result   = "<h3>EHS Assessment " + ((IsEditContext) ? "Updated" : "Created") + ":</h3>";

            // Edit context
            videoId = EditVideoId;
            if (videoId > 0)
            {
                theVideo = UpdateVideo(videoId);
                SaveAttachments(videoId);
            }


            if (shouldReturn == true)
            {
                divForm.Visible = false;

                pnlAddEdit.Visible    = false;
                btnSaveReturn.Visible = false;

                RadCodeBlock rcbWarnNavigate = (RadCodeBlock)this.Parent.Parent.FindControl("rcbWarnNavigate");
                if (rcbWarnNavigate != null)
                {
                    rcbWarnNavigate.Visible = false;
                }

                lblResults.Visible = true;
            }
            else
            {
                EditVideoId = videoId;
                SessionManager.ReturnRecordID = videoId;
                CurrentStep   = 0;
                IsEditContext = true;
                Visible       = true;

                // and send a message that the field need to be entered
                string script = string.Format("alert('{0}');", Resources.LocalizedText.AssessmentRequiredsIndicatedMsg);
                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", script, true);
            }

            if (shouldReturn)
            {
                SessionManager.ReturnStatus = false;
                SessionManager.ReturnObject = "DisplayVideos";
                Response.Redirect("/Media/Media_Videos.aspx");
            }
        }
Esempio n. 13
0
        // GET: VIDEOs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VIDEO vIDEO = db.VIDEO.Find(id);

            if (vIDEO == null)
            {
                return(HttpNotFound());
            }
            ViewBag.categoria = new SelectList(db.CATEGORIA, "id_categoria", "nombre", vIDEO.categoria);
            return(View(vIDEO));
        }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     if (EditVideoId > 0)
     {
         btnSaveReturn.Visible = false;
         //btnSaveContinue.Visible = false;
         btnDelete.Visible  = false;
         lblResults.Visible = true;
         VIDEO video = MediaVideoMgr.SelectVideoById(EditVideoId);
         //string filename = Server.MapPath(video.FILE_NAME);
         int delStatus = MediaVideoMgr.DeleteVideo(EditVideoId, video.FILE_NAME);
         // delete the task
         lblResults.Text  = "<div style=\"text-align: center; font-weight: bold; padding: 10px;\">";
         lblResults.Text += (delStatus == 1) ? Resources.LocalizedText.VideoDeleted : Resources.LocalizedText.VideoErrorDeleting;
         lblResults.Text += "</div>";
     }
 }
 public void SetVideo(Model.VIDEO video)
 {
     try
     {
         videoI           = video;
         Media.Source     = new Uri(video.LinkVideo);
         sliderTime.Value = 0;
         GMedia.Height    = 40;
         Media.Play();
     }
     catch
     {
         ////new duong dan ko den được video nào thì xuất hình thông báo lỗi
         //Media.Source = new Uri(@"E:\HoangTrung\LTUDQL2\LTUDQL2---DACK\1660661\01.png");
         //GMedia.Height = 0;
     }
 }
        protected void rgFiles_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem item    = (GridEditableItem)e.Item;
            decimal          videoId = (decimal)item.GetDataKeyValue("VideoId");
            VIDEO            video   = MediaVideoMgr.SelectVideoById(videoId);
            //string filename = Server.MapPath(video.FILE_NAME);
            int status = MediaVideoMgr.DeleteVideo(videoId, video.FILE_NAME);

            this.GetUploadedFiles();

            if (AttachmentEvent != null)
            {
                SessionManager.ReturnRecordID = video.VIDEO_ID;
                SessionManager.ReturnObject   = "AddVideo";
                SessionManager.ReturnStatus   = true;
                AttachmentEvent("delete");
            }
        }
Esempio n. 17
0
 // POST: Admin/Video/Them
 public ActionResult Them(VIDEO vdo)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         if (vdo.NgayDang == null)
         {
             vdo.NgayDang = DateTime.Parse(DateTime.Now.ToString());
         }
         else
         {
             vdo.NgayDang = vdo.NgayDang;
         }
         db.VIDEOs.Add(vdo);
         ViewBag.IdAlbum    = new SelectList(db.ALBUMs.ToList(), "IdAlbum", "TenAlbum");
         ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
        protected VIDEO UpdateVideo(decimal videoId)
        {
            // we are not going to let them update any of this info.
            VIDEO video = (from i in entities.VIDEO where i.VIDEO_ID == videoId select i).FirstOrDefault();

            if (video != null)
            {
                video.TITLE              = tbTitle.Text.ToString();
                video.DESCRIPTION        = tbDescription.Text.ToString();
                video.VIDEO_TYPE         = ddlVideoType.SelectedValue.ToString();
                video.VIDEO_AVAILABILITY = ddlAvailability.SelectedValue.ToString();
                video.VIDEO_STATUS       = rcbStatusSelect.SelectedValue.ToString();
                video.RELEASE_REQUIRED   = cbReleaseForms.Checked;
                video.TEXT_ADDED         = cbVideoText.Checked;
                video.SPEAKER_AUDIO      = cbSpeakerAudio.Checked;
                entities.SaveChanges();
            }

            return(video);
        }
Esempio n. 19
0
        protected void lbUpload_Click(object sender, EventArgs e)
        {
            string name          = "";
            string fileExtension = "";
            string fileLocation  = "~/Videos/";

            if (flFileUpload.HasFile)
            {
                name          = flFileUpload.FileName;
                fileExtension = flFileUpload.FileName.Substring(flFileUpload.FileName.IndexOf(".") + 1);
                // check to see if this is a video?

                Stream stream = flFileUpload.FileContent;
                // first we need to create the video header (String fileLocation, String fileExtention, String description, string videoTitle, int sourceType, decimal sourceId, string sourceStep, string injuryType, string bodyPart, string docScope, DateTime videoDate, DateTime incidentDate)
                VIDEO video = MediaVideoMgr.Add(name, fileExtension, tbFileDescription.Text.ToString(), tbTitle.Text.ToString(), SourceType, SourceId, SourceStep, ddlInjuryType.SelectedValue.ToString(), rdlBodyPart.SelectedValue.ToString(), "", (DateTime)dmFromDate.SelectedDate, SourceDate, stream, 0);
                // next, save the video to the server; file name = VIDEO_ID
                //////string fileName = "";
                //////DateTime dtIncidentDate = new DateTime();
                //////// next we create the video header
                //////if (video != null)
                //////{
                //////	// Bind_gvUploadedFiles(); - we are NOT going to bind the video, because we are only allowing ONE at a time
                //////	// mt - put the new document and upload status in session so that we can retrieve it (if necessary) from the calling page
                //////	try
                //////	{
                //////		flFileUpload.SaveAs(video.FILE_NAME);
                //////		SessionManager.ReturnObject = video;
                //////		SessionManager.ReturnStatus = true;
                //////	}
                //////	catch (Exception ex)
                //////	{
                //////		// put up an error
                //////	}
                //////}
                //////else
                //////{
                //////	SessionManager.ClearReturns();
                //////}
            }
        }
Esempio n. 20
0
 public FilmInfo(MainWindow frm)
 {
     InitializeComponent();
     Child    = frm;
     filminfo = new VIDEO();
 }
Esempio n. 21
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.Clear();

                if (!String.IsNullOrEmpty(context.Request.QueryString["DOC_ID"]))
                {
                    String document_id = context.Request.QueryString["DOC_ID"];
                    String fileName    = "attachment";

                    Decimal doc_id   = decimal.Parse(document_id);
                    string  fileType = "";
                    String  mimeType = "";

                    if (!string.IsNullOrEmpty(context.Request.QueryString["DOC"]))
                    {
                        switch (context.Request.QueryString["DOC"])
                        {
                        case "a":                                 // attachment
                            ATTACHMENT a = SQMDocumentMgr.GetAttachment(doc_id);
                            fileType = Path.GetExtension(a.FILE_NAME);

                            if (!string.IsNullOrEmpty(context.Request.QueryString["FILE_NAME"]))
                            {
                                fileName = context.Request.QueryString["FILE_NAME"];
                            }
                            else
                            {
                                fileName += fileType;
                            }

                            mimeType = SQM.Website.Classes.FileExtensionConverter.ToMIMEType(fileType);
                            context.Response.ContentType = mimeType;
                            //context.Response.BinaryWrite(a.ATTACHMENT_FILE.ATTACHMENT_DATA);

                            // mt  - use below for video streams ?
                            context.Response.AddHeader("content-disposition", "inline; filename=" + fileName);
                            context.Response.AddHeader("content-length", a.ATTACHMENT_FILE.ATTACHMENT_DATA.Length.ToString());
                            context.Response.OutputStream.Write(a.ATTACHMENT_FILE.ATTACHMENT_DATA, 0, a.ATTACHMENT_FILE.ATTACHMENT_DATA.Length);
                            context.Response.Flush();
                            break;

                        case "v":                                 // video
                            VIDEO v = MediaVideoMgr.SelectVideoById(doc_id);

                            // get the file from Azure
                            fileType = Path.GetExtension(v.FILE_NAME);

                            if (!string.IsNullOrEmpty(context.Request.QueryString["FILE_NAME"]))
                            {
                                fileName = context.Request.QueryString["FILE_NAME"];
                            }
                            else
                            {
                                fileName += fileType;
                            }

                            List <SETTINGS> sets               = SQMSettings.SelectSettingsGroup("MEDIA_UPLOAD", "");
                            string          storageContainer   = sets.Find(x => x.SETTING_CD == "STORAGE_CONTAINER").VALUE.ToString();
                            string          storageURL         = sets.Find(x => x.SETTING_CD == "STORAGE_URL").VALUE.ToString();
                            string          storageQueryString = sets.Find(x => x.SETTING_CD == "STORAGE_QUERY").VALUE.ToString();

                            // Retrieve storage account from connection string.
                            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                                CloudConfigurationManager.GetSetting("StorageConnectionString"));

                            // Create the blob client.
                            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                            // Retrieve reference to a previously created container.
                            CloudBlobContainer container = blobClient.GetContainerReference(storageContainer);

                            // Retrieve reference to a blob named "photo1.jpg".
                            CloudBlockBlob blockBlob = container.GetBlockBlobReference(v.VIDEO_ID + fileType);

                            // Save blob contents to a file.
                            //using (var fileStream = System.IO.File.OpenWrite(@"path\myfile"))
                            //{
                            //	blockBlob.DownloadToStream(fileStream);
                            //}

                            mimeType = SQM.Website.Classes.FileExtensionConverter.ToMIMEType(fileType);
                            context.Response.ContentType = mimeType;

                            byte[] b = new byte[16 * 1024];
                            using (MemoryStream memoryStream = new MemoryStream())
                            {
                                blockBlob.DownloadToStream(memoryStream);
                                //memoryStream.WriteTo(HttpContext.Current.Response.OutputStream);
                                //memoryStream.Close();
                                b = memoryStream.ToArray();
                            }

                            context.Response.AddHeader("content-disposition", "inline; filename=" + fileName);
                            context.Response.AddHeader("content-length", v.FILE_SIZE.ToString());
                            context.Response.BinaryWrite(b);
                            context.Response.Flush();

                            //// the following is the code for finding the file in the database
                            //VIDEO_FILE vf = MediaVideoMgr.SelectVideoFileById(doc_id);

                            //fileType = Path.GetExtension(v.FILE_NAME);

                            //if (!string.IsNullOrEmpty(context.Request.QueryString["FILE_NAME"]))
                            //	fileName = context.Request.QueryString["FILE_NAME"];
                            //else
                            //	fileName += fileType;

                            //mimeType = SQM.Website.Classes.FileExtensionConverter.ToMIMEType(fileType);
                            //context.Response.ContentType = mimeType;

                            //// mt  - use below for video streams ?
                            //context.Response.AddHeader("content-disposition", "inline; filename=" + fileName);
                            //context.Response.AddHeader("content-length", vf.VIDEO_DATA.Length.ToString());
                            ////context.Response.OutputStream.Write(vf.VIDEO_DATA, 0, vf.VIDEO_DATA.Length);
                            //context.Response.BinaryWrite(vf.VIDEO_DATA);

                            //context.Response.Flush();

                            //// the following is the code for finding the file on the server
                            //fileType = Path.GetExtension(v.FILE_NAME);

                            //fileName = context.Server.MapPath(v.FILE_NAME);
                            //System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);

                            //try
                            //{
                            //	if (fileInfo.Exists)
                            //	{
                            //		context.Response.Clear();
                            //		context.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + fileInfo.Name + "\"");
                            //		context.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                            //		context.Response.ContentType = "application/octet-stream";
                            //		context.Response.TransmitFile(fileInfo.FullName);
                            //		context.Response.Flush();
                            //	}
                            //	else
                            //	{
                            //		throw new Exception("File not found");
                            //	}
                            //}
                            //catch (Exception ex)
                            //{
                            //	context.Response.ContentType = "text/plain";
                            //	context.Response.Write(ex.Message);
                            //}
                            //finally
                            //{
                            //	context.Response.End();
                            //}
                            break;

                        case "va":                                 // video attachment
                            VIDEO_ATTACHMENT va = SQMDocumentMgr.GetVideoAttachment(doc_id);
                            fileType = Path.GetExtension(va.FILE_NAME);

                            if (!string.IsNullOrEmpty(context.Request.QueryString["FILE_NAME"]))
                            {
                                fileName = context.Request.QueryString["FILE_NAME"];
                            }
                            else
                            {
                                fileName += fileType;
                            }

                            mimeType = SQM.Website.Classes.FileExtensionConverter.ToMIMEType(fileType);
                            context.Response.ContentType = mimeType;
                            //context.Response.BinaryWrite(a.ATTACHMENT_FILE.ATTACHMENT_DATA);

                            // mt  - use below for video streams ?
                            context.Response.AddHeader("content-disposition", "inline; filename=" + fileName);
                            context.Response.AddHeader("content-length", va.VIDEO_ATTACHMENT_FILE.VIDEO_ATTACH_DATA.Length.ToString());
                            context.Response.OutputStream.Write(va.VIDEO_ATTACHMENT_FILE.VIDEO_ATTACH_DATA, 0, va.VIDEO_ATTACHMENT_FILE.VIDEO_ATTACH_DATA.Length);
                            context.Response.Flush();
                            break;

                        default:                                 // document
                            DOCUMENT d = SQMDocumentMgr.GetDocument(doc_id);
                            fileType = Path.GetExtension(d.FILE_NAME);
                            // set this to whatever your format is of the image
                            context.Response.ContentType = fileType;
                            mimeType = SQM.Website.Classes.FileExtensionConverter.ToMIMEType(fileType);
                            context.Response.ContentType = mimeType;
                            //context.Response.AddHeader("content-length", d.DOCUMENT_DATA.Length.ToString());
                            //context.Response.OutputStream.Write(d.DOCUMENT_DATA, 0, d.DOCUMENT_DATA.Length);
                            context.Response.AddHeader("content-length", d.DOCUMENT_FILE.DOCUMENT_DATA.Length.ToString());
                            context.Response.OutputStream.Write(d.DOCUMENT_FILE.DOCUMENT_DATA, 0, d.DOCUMENT_FILE.DOCUMENT_DATA.Length);
                            context.Response.Flush();
                            break;
                        }
                    }
                }

                else
                {
                    context.Response.ContentType = "text/html";
                    context.Response.Write("<p>Document not found</p>");
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }
        }
Esempio n. 22
0
        public FilmInfo()
        {
            InitializeComponent();

            filminfo = new VIDEO();
        }
Esempio n. 23
0
        public static VIDEO Add(String fileName, String fileExtention, String description, string videoTitle, int sourceType, decimal sourceId, string sourceStep, string injuryType, string bodyPart, string videoType, DateTime videoDate, DateTime incidentDate, Stream file, decimal plantId)
        {
            VIDEO ret = null;

            try
            {
                using (PSsqmEntities entities = new PSsqmEntities())
                {
                    VIDEO video = new VIDEO();
                    //video.FILE_NAME = filename;
                    video.DESCRIPTION = description;
                    video.TITLE       = videoTitle;
                    video.SOURCE_TYPE = sourceType;
                    video.SOURCE_ID   = sourceId;
                    video.SOURCE_STEP = sourceStep;

                    if (plantId > 0)
                    {
                        PLANT plant = SQMModelMgr.LookupPlant(plantId);
                        video.COMPANY_ID = (decimal)plant.COMPANY_ID;
                        video.BUS_ORG_ID = (decimal)plant.BUS_ORG_ID;
                        video.PLANT_ID   = plantId;
                    }
                    else
                    {
                        video.COMPANY_ID = SessionManager.EffLocation.Company.COMPANY_ID;
                        video.BUS_ORG_ID = SessionManager.UserContext.Person.BUS_ORG_ID;
                        video.PLANT_ID   = SessionManager.UserContext.Person.PLANT_ID;
                    }

                    video.VIDEO_PERSON = SessionManager.UserContext.Person.PERSON_ID;
                    video.CREATE_DT    = WebSiteCommon.CurrentUTCTime();
                    video.VIDEO_TYPE   = videoType;                   // this is the injury/incident type.  Default to 0 for Media & audit
                    video.VIDEO_DT     = videoDate;
                    video.INCIDENT_DT  = incidentDate;
                    video.INJURY_TYPES = injuryType;
                    video.BODY_PARTS   = bodyPart;
                    video.VIDEO_STATUS = "";
                    //video.FILE_NAME = fileName;
                    video.FILE_SIZE = file.Length;

                    entities.AddToVIDEO(video);
                    entities.SaveChanges();

                    // use the video id, but have to save video
                    video.FILE_NAME = video.VIDEO_ID.ToString() + fileExtention;
                    entities.SaveChanges();

                    // this is the code for saving the file in the Azure cloud
                    if (video != null)
                    {
                        // get the container from the settings table
                        List <SETTINGS> sets             = SQMSettings.SelectSettingsGroup("MEDIA_UPLOAD", "");
                        string          storageContainer = sets.Find(x => x.SETTING_CD == "STORAGE_CONTAINER").VALUE.ToString();

                        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                            CloudConfigurationManager.GetSetting("StorageConnectionString"));
                        CloudBlobClient    blobClient = storageAccount.CreateCloudBlobClient();
                        CloudBlobContainer container  = blobClient.GetContainerReference(storageContainer);
                        CloudBlockBlob     blockBlob  = container.GetBlockBlobReference(video.VIDEO_ID.ToString() + fileExtention);
                        blockBlob.UploadFromStream(file);
                    }

                    ret = video;
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
                ret = null;
            }

            return(ret);
        }