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 = "";
                    }
                }
            }
        }
        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");
                }
            }
        }
 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>";
     }
 }
        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");
            }
        }
예제 #5
0
        protected void lbDelete_Click(object sender, EventArgs e)
        {
            RadButton lb = (RadButton)sender;

            decimal videoId = 0;

            try
            {
                videoId = Convert.ToDecimal(lb.CommandArgument.ToString());
            }
            catch { }
            if (videoId > 0)
            {
                //string videoname = Server.MapPath(lb.CommandName.ToString());
                int status = MediaVideoMgr.DeleteVideo(videoId, lb.CommandName.ToString());
            }
            SessionManager.ReturnStatus   = true;
            SessionManager.ReturnObject   = "DisplayVideos";
            SessionManager.ReturnRecordID = 0;
        }
예제 #6
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();
                //////}
            }
        }
        private void OnTextUpdate(string cmd)
        {
            // update the page
            List <MediaVideoData> videos = MediaVideoMgr.SelectVideoDataById(entities, EditVideoId);

            if (videos != null)
            {
                MediaVideoData videoData = videos[0];
                GetAttachments(EditVideoId, (int)MediaAttachmentType.Text, videoData.VideoTextList.Count);
                if (videoData.Video.TEXT_ADDED || videoData.VideoTextList.Count > 0)
                {
                    cbVideoText.Checked = true;
                    //dvText.Visible = true;
                    dvText.Style.Add("display", "block");
                }
                else
                {
                    cbVideoText.Checked = false;
                    //dvText.Visible = false;
                    dvText.Style.Add("display", "none");
                }
            }
        }
예제 #8
0
        private void SearchVideos()
        {
            string   selectedValue = "";
            DateTime fromDate      = Convert.ToDateTime(dmFromDate.SelectedDate);
            DateTime toDate        = Convert.ToDateTime(dmToDate.SelectedDate);

            if (toDate < fromDate)
            {
                return;
            }

            toDate = new DateTime(toDate.Year, toDate.Month, toDate.Day, 23, 59, 59);

            List <decimal> plantIDS   = SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToList();
            List <string>  videoTypes = SQMBasePage.GetComboBoxCheckedItems(rcbVideoType).Select(i => i.Value).ToList();

            string         selectedType = rcbVideoSource.SelectedValue.ToString();
            List <decimal> types        = new List <decimal>();

            if (rcbVideoSource.SelectedValue.ToString().Equals(""))
            {
                types.Add(0);
            }
            else
            {
                foreach (RadComboBoxItem item in rcbVideoSource.Items)
                {
                    if (!item.Value.Equals("") && item.Selected)
                    {
                        types.Add(Convert.ToDecimal(item.Value.ToString()));
                    }
                }
            }

            List <string> injuryTypes = new List <string>();

            if (rcbInjuryType.SelectedValue.ToString().Equals(""))
            {
                injuryTypes.Add("0");
            }
            else
            {
                foreach (RadComboBoxItem item in rcbInjuryType.Items)
                {
                    if (!item.Value.Equals("") && item.Selected)
                    {
                        injuryTypes.Add(item.Value.ToString());
                    }
                }
            }

            List <string> bodyParts = new List <string>();

            if (rcbBodyPart.SelectedValue.ToString().Equals(""))
            {
                bodyParts.Add("0");
            }
            else
            {
                foreach (RadComboBoxItem item in rcbBodyPart.Items)
                {
                    if (!item.Value.Equals("") && item.Selected)
                    {
                        bodyParts.Add(item.Value.ToString());
                    }
                }
            }

            string  videoOwner   = rcbVideoOwner.SelectedValue.ToString();
            decimal videoOwnerId = 0;

            if (videoOwner == "own")
            {
                videoOwnerId = SessionManager.UserContext.Person.PERSON_ID;
            }

            List <MediaVideoData> videos = MediaVideoMgr.SelectVideoList(plantIDS, types, fromDate, toDate, rcbVideoStatusSelect.SelectedValue.ToString(), tbKeyWord.Text.ToString().ToLower(), injuryTypes, bodyParts, videoTypes, videoOwnerId);

            // we don't want to list any videos that have a negative source id. these could be videos in process or orphaned on the Incident pages
            videos = videos.Where(q => q.Video.SOURCE_ID >= 0).ToList();
            uclVideoList.BindVideoListRepeater(videos, "Media");
            //List<string> statusList = new List<string>();

            //	typeList = rcbVideoType.Items.Where(c => c.Checked).Select(c => Convert.ToDecimal(c.Value)).ToList();
            //	selectedValue = rcbVideoStatusSelect.SelectedValue;

            //SetHSCalcs(new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "0", fromDate, toDate, new decimal[0]));
            //HSCalcs().ehsCtl = new EHSCalcsCtl().CreateNew(1, DateSpanOption.SelectRange);
            ////HSCalcs().ObjAny = cbShowImage.Checked;

            //HSCalcs().ehsCtl.SelectAuditList(plantIDS, typeList, fromDate, toDate, selectedValue);

            //// may want to access only the ones assigned to that person
            ////if (accessLevel < AccessMode.Admin)
            ////	HSCalcs().ehsCtl.AuditHst = (from i in HSCalcs().ehsCtl.AuditHst where i.Audit.ISSUE_TYPE_ID != 10 select i).ToList();
            //bool allAuditAccess = SessionManager.CheckUserPrivilege(SysPriv.admin, SysScope.audit);
            //if (!allAuditAccess)
            //	HSCalcs().ehsCtl.AuditHst = (from i in HSCalcs().ehsCtl.AuditHst where i.Audit.AUDIT_PERSON == SessionManager.UserContext.Person.PERSON_ID select i).ToList();

            //if (HSCalcs().ehsCtl.AuditHst != null)
            //{
            //	HSCalcs().ehsCtl.AuditHst.OrderByDescending(x => x.Audit.AUDIT_DT);
            //	uclAuditList.BindAuditListRepeater(HSCalcs().ehsCtl.AuditHst, "EHS");
            //}
            ////}

            //pnlAuditDetails.Visible = lnkAuditDetailsClose.Visible = false;
        }
        public void LoadVideoInformation()
        {
            // populate all the fields
            List <XLAT> listXLAT = SQMBasePage.SelectXLATList(new string[5] {
                "INJURY_PART", "INJURY_TYPE", "MEDIA_VIDEO_SOURCE", "MEDIA_VIDEO_STATUS", "MEDIA_VIDEO_TYPE"
            }, 1);
            List <MediaVideoData> videos = MediaVideoMgr.SelectVideoDataById(entities, EditVideoId);

            if (videos != null)
            {
                MediaVideoData   videoData = videos[0];
                BusinessLocation location  = new BusinessLocation().Initialize((decimal)videoData.Video.PLANT_ID);
                lblVideoSourceType.Text = ((TaskRecordType)videoData.Video.SOURCE_TYPE).ToString();
                if ((TaskRecordType)videoData.Video.SOURCE_TYPE != TaskRecordType.Media)
                {
                    lblVideoSourceType.Text += " " + videoData.Video.SOURCE_ID;
                }
                lblVideoLocation.Text   = location.Plant.PLANT_NAME + " " + location.BusinessOrg.ORG_NAME;
                lblVideoPersonName.Text = videoData.Person.LAST_NAME + ", " + videoData.Person.FIRST_NAME;
                DateTime dt = (DateTime)videoData.Video.VIDEO_DT;
                lblVideoDate.Text = dt.ToString("MM/dd/yyyy");
                dt = (DateTime)videoData.Video.INCIDENT_DT;
                lblVideoIncidentDate.Text = dt.ToString("MM/dd/yyyy");
                lblVideoInjuryType.Text   = SQMBasePage.GetXLAT(listXLAT, "INJURY_TYPE", videoData.Video.INJURY_TYPES).DESCRIPTION;           // for now we assume only one
                lblVideoBodyPart.Text     = SQMBasePage.GetXLAT(listXLAT, "INJURY_PART", videoData.Video.BODY_PARTS).DESCRIPTION;             // for now we assume only one

                tbTitle.Text       = videoData.Video.TITLE;
                tbDescription.Text = videoData.Video.DESCRIPTION;
                if (ddlVideoType.Items.Count == 0)
                {
                    PopulateVideoTypeDropDown();
                }
                if (videoData.Video.VIDEO_TYPE == null)
                {
                    ddlVideoType.SelectedValue = "";
                }
                else
                {
                    ddlVideoType.SelectedValue = videoData.Video.VIDEO_TYPE;
                }
                if (videoData.Video.VIDEO_AVAILABILITY == null)
                {
                    ddlAvailability.SelectedIndex = 0;
                }
                else
                {
                    ddlAvailability.SelectedValue = videoData.Video.VIDEO_AVAILABILITY;
                }
                litVideoDownloadLink.Text = "<a href='/Shared/FileHandler.ashx?DOC=v&DOC_ID=" + EditVideoId + "&FILE_NAME=" + videoData.Video.FILE_NAME + "' target='_blank'>" + Resources.LocalizedText.VideoDownload + "</a>";
                litVideoViewLink.Text     = "<a href='/Shared/VideoHandler.aspx?DOC=v&DOC_ID=" + EditVideoId + "' target='_blank'>" + Resources.LocalizedText.VideoView + "</a>";
                rcbStatusSelect           = SQMBasePage.SetComboBoxItemsFromXLAT(rcbStatusSelect, listXLAT.Where(l => l.XLAT_GROUP == "MEDIA_VIDEO_STATUS" && l.STATUS == "A").OrderBy(h => h.SORT_ORDER).ToList(), "SHORT");
                rcbStatusSelect.Items.Insert(0, new RadComboBoxItem("Select a status", ""));
                rcbStatusSelect.SelectedValue = videoData.Video.VIDEO_STATUS;
                cbVideoText.Checked           = videoData.Video.SPEAKER_AUDIO;

                // populate release form list
                if (videoData.Video.RELEASE_REQUIRED)
                {
                    cbReleaseForms.Checked = true;
                    //dvAttach.Visible = true;
                    dvAttach.Style.Add("display", "block");
                    // get the new async working
                    GetAttachments(EditVideoId, (int)MediaAttachmentType.ReleaseForm, videoData.ReleaseFormList.Count);
                }
                else
                {
                    cbReleaseForms.Checked = false;
                    //dvAttach.Visible = false;
                    dvAttach.Style.Add("display", "none");
                }
                uploadReleases.SetViewMode(true);
                // populate text list
                GetAttachments(EditVideoId, (int)MediaAttachmentType.Text, videoData.VideoTextList.Count);
                if (videoData.Video.TEXT_ADDED || videoData.VideoTextList.Count > 0)
                {
                    cbVideoText.Checked = true;
                    //dvText.Visible = true;
                    dvText.Style.Add("display", "block");
                }
                else
                {
                    cbVideoText.Checked = false;
                    //dvText.Visible = false;
                    dvText.Style.Add("display", "none");
                }

                pnlAddEdit.Visible     = true;
                pnlVideoHeader.Visible = true;
                divVideoForm.Visible   = true;

                if (videoData.Video.SOURCE_TYPE == (int)TaskRecordType.Audit || videoData.Video.SOURCE_TYPE == (int)TaskRecordType.HealthSafetyIncident)
                {
                    btnDelete.Visible = false;
                }
                else
                {
                    btnDelete.Visible = true;
                }

                // if not edit mode, all fields are display only
                if (!IsEditContext)
                {
                    tbTitle.Enabled         = false;
                    tbDescription.Enabled   = false;
                    ddlAvailability.Enabled = false;
                    ddlVideoType.Enabled    = false;
                    cbReleaseForms.Enabled  = false;
                    cbVideoText.Enabled     = false;
                    cbSpeakerAudio.Enabled  = false;
                }
            }
        }