Beispiel #1
0
        public void SaveFiles()
        {
            string[] descriptions = hfDescriptions.Value.Split('|');

            int i = 0;

            foreach (UploadedFile file in raUpload.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;
                SQMDocumentMgr.AddAttachment(
                    file.FileName,
                    description,
                    displayType,
                    "",
                    SessionManager.DocumentContext.RecordType,
                    SessionManager.DocumentContext.RecordID,
                    SessionManager.DocumentContext.RecordStep,
                    Session.SessionID,
                    file.InputStream
                    );
                i++;
            }

            // Update "display" status of existing files
            foreach (GridDataItem item in rgFiles.Items)
            {
                decimal  attachmentId = Convert.ToDecimal(item.GetDataKeyValue("AttachmentId"));
                CheckBox cb           = (CheckBox)item["DisplayTypeColumn"].FindControl("checkBox");
                decimal  displayType  = (cb.Checked) ? 1 : 0;
                SQMDocumentMgr.UpdateAttachmentDisplayType(attachmentId, displayType);
            }
        }
        protected void lbUpload_Click(object sender, EventArgs e)
        {
            string name = "";

            if (flFileUpload.HasFile)
            {
                name = flFileUpload.FileName;

                Stream stream = flFileUpload.FileContent;
                // string sessionID = Session.SessionID;
                ATTACHMENT d = SQMDocumentMgr.AddAttachment(flFileUpload.FileName, tbFileDescription.Text, 0, "", SessionManager.DocumentContext.RecordType, SessionManager.DocumentContext.RecordID, SessionManager.DocumentContext.RecordStep, Session.SessionID, stream, 0);//apply 0 for incident attchment.
                if (d != null)
                {
                    Bind_gvUploadedFiles();
                    // mt - put the new document and upload status in session so that we can retrieve it (if necessary) from the calling page
                    SessionManager.ReturnObject = d;
                    SessionManager.ReturnStatus = true;
                }
                else
                {
                    SessionManager.ClearReturns();
                }
            }
        }