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");
                }
            }
        }
示例#3
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();
                //////}
            }
        }