Exemple #1
0
        public void SaveFiles(int recordType, decimal recordId)
        {
            string[] descriptions = hfDescriptions.Value.Split('|');

            int i = 0;

            foreach (UploadedFile file in raVideoUpload.UploadedFiles)
            {
                string  description = (i < descriptions.Count()) ? descriptions[i] : "";
                decimal displayType = (file.FileName.ToLower().Contains(".jpeg") || file.FileName.ToLower().Contains(".jpg") ||
                                       file.FileName.ToLower().Contains(".gif") || file.FileName.ToLower().Contains(".png")) ||
                                      file.FileName.ToLower().Contains(".bmp") ? 1 : 0;
                switch (recordType)
                {
                case (int)MediaAttachmentType.ReleaseForm:
                    SQMDocumentMgr.AddVideoAttachment(
                        file.FileName,
                        description,
                        "",
                        displayType,
                        recordType,
                        recordId,
                        Session.SessionID,
                        file.InputStream
                        );
                    break;

                default:                         // text entries
                    SQMDocumentMgr.AddVideoAttachment(
                        file.FileName,
                        description,
                        "",
                        displayType,
                        recordType,
                        recordId,
                        Session.SessionID,
                        file.InputStream
                        );
                    break;
                }
                i++;
            }

            // Update "display" status of existing files
            foreach (GridDataItem item in rgVideoFiles.Items)
            {
                decimal  attachmentId = Convert.ToDecimal(item.GetDataKeyValue("VideoAttachId"));
                CheckBox cb           = (CheckBox)item["DisplayTypeColumn"].FindControl("checkBox");
                decimal  displayType  = (cb.Checked) ? 1 : 0;
                SQMDocumentMgr.UpdateAttachmentDisplayType(attachmentId, displayType);
            }
        }
        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 (hdnVideoAttachId.Value.ToString().Equals(""))
            {
                SQMDocumentMgr.AddVideoAttachment(
                    "",
                    tbText.Text.ToString(),
                    tbTimestamp.Text.ToString(),
                    0,
                    _recordType,
                    _recordId,
                    Session.SessionID,
                    null
                    );
            }
            else
            {
                decimal videoAttachId = Convert.ToDecimal(hdnVideoAttachId.Value.ToString());
                SQMDocumentMgr.UpdateVideoAttachment(
                    videoAttachId,
                    "",
                    tbText.Text.ToString(),
                    tbTimestamp.Text.ToString(),
                    0,
                    _recordType,
                    _recordId,
                    Session.SessionID,
                    null
                    );
            }

            this.GetUploadedFiles(_recordType, _recordId);
            tbTimestamp.Text       = "";
            tbText.Text            = "";
            hdnVideoAttachId.Value = "";

            //if (AttachmentEvent != null)
            //{
            AttachmentEvent("save");
            //}
        }