Beispiel #1
0
        private void setSignatureLink(DataRow signatureRecord)
        {
            string fileId        = signatureRecord[UploadedFile.FileId].ToString();
            string fileExtension = signatureRecord[UploadedFile.FileExtension].ToString();
            string fileLabel     = signatureRecord[UploadedFile.FileLabel].ToString();

            AddSignatureLink.Style["display"] = "none";
            SignatureImage.Style["display"]   = "";

            UploadedFile biz = new UploadedFile();

            biz.Get(int.Parse(fileId));
            SignatureImage.ImageUrl = "../Plugins/FileLoader/DocumentLoader.aspx?fileId=" + Security.CustomCryptoHelper.Encrypt(fileId);
            SignatureImage.ToolTip  = "Click to view or change signature.";
        }
Beispiel #2
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            string fId     = Request.QueryString["fileId"];
            string thumb   = Request.QueryString["thumb"];
            bool   isThumb = !string.IsNullOrEmpty(thumb) && thumb.ToLower() == bool.TrueString.ToLower() ? true : false;


            // Load file by field id
            if (!string.IsNullOrEmpty(fId))
            {
                int    fileId          = -1;
                string decrypyedFileId = Security.CustomCryptoHelper.Decrypt(fId);
                int.TryParse(decrypyedFileId, out fileId);

                UploadedFile userFile = new UploadedFile();
                userFile.Get(fileId);
                WriteFile(userFile, isThumb);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Displays thumbnail if one exists and property set to true, otherwise display file Label. Default to display generic "Upload File" image
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="tablePrimaryKey"></param>
        private void DisplayLink(string tableName, string tablePrimaryKey)
        {
            string _savePath = System.Configuration.ConfigurationSettings.AppSettings["FileUploadLocation"].ToString() + this.PrimaryKeyTable;

            _savePath = Page.ResolveUrl(_savePath);

            // Cheeck to see if files are uploaded for this record
            FilesDa da = new FilesDa();
            DataSet ds = da.GetRecordsByTableAndTablePK(this.PrimaryKeyTable, int.Parse(tablePrimaryKey));

            // If files are uploaded, show thumb for default
            if (ds.Tables[0].Rows.Count > 0)
            {
                string fileId        = ds.Tables[0].Rows[0][UploadedFile.FileId].ToString();
                string fileExtension = ds.Tables[0].Rows[0][UploadedFile.FileExtension].ToString();
                string fileLabel     = ds.Tables[0].Rows[0][UploadedFile.FileLabel].ToString();

                bool isFileAnImage = FileLoaderUtil.IsImage(fileExtension);

                // show thumbnail of image
                if (_showThumbNail == true && isFileAnImage)
                {
                    linkText.Visible  = false;
                    linkImage.Visible = true;
                    UploadedFile biz = new UploadedFile();
                    biz.Get(int.Parse(fileId));

                    linkImage.ImageUrl = "DocumentLoader.aspx?fileId=" + Security.CustomCryptoHelper.Encrypt(fileId) + "&thumb=true";
                    linkImage.Attributes.Add("style", "border: solid 1px #cccccc; cursor: pointer;");
                    linkImage.ToolTip = "Click to view or edit this image.";
                }
                // show file label as link
                else if (!string.IsNullOrEmpty(fileLabel))
                {
                    //link.InnerHtml = "View " + fileLabel;
                    linkText.Text     = "View " + fileLabel;
                    linkText.Visible  = true;
                    linkImage.Visible = false;
                    link.Attributes.Add("style", "cursor: pointer;");
                }
                // default to showing generic view file image
                else
                {
                    linkText.Visible   = false;
                    linkImage.Visible  = true;
                    linkImage.ImageUrl = "~/Images/ViewFile.gif";
                }
            }
            else if (!string.IsNullOrEmpty(_linkName))
            {
                //link.InnerHtml = _linkName;
                linkText.Text     = _linkName;
                linkText.Visible  = true;
                linkImage.Visible = false;
            }
            else
            {
                linkText.Visible   = false;
                linkImage.Visible  = true;
                linkImage.ImageUrl = "~/Images/UploadFile.gif";
            }

            // Register's function for setting thumb image on plugin
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ImageReloader", "function setThumb(newSrc) {  var pluginTmb = document.getElementById('" + linkImage.ClientID + "'); if(pluginTmb) { pluginTmb.src = newSrc; } }", true);
        }
Beispiel #4
0
        protected override void Page_Load(object sender, System.EventArgs e)
        {
            // defaults
            Page.EnableViewState      = false;
            UploadPanel.Visible       = false;
            ViewPanel.Visible         = false;
            MainImg.Visible           = false;
            ThumbnailExplorer.Visible = false;

            // reset messages
            UploadMsg.Text      = "Please enter the file name and provide a label below.";
            ThumbMsg.Text       = "";
            UploadErrorMsg.Text = String.Empty;

            // view or add image; url params created in code behind of plugin control
            if ((Request.QueryString["tableName"] != null && Request.QueryString["tableName"].Length > 0) && (Request.QueryString["primaryKey"] != null && Request.QueryString["primaryKey"].Length > 0))
            {
                // SET tableName/tablePriKey from QueryString
                _tableName       = Request.QueryString["tableName"];
                _tablePrimaryKey = int.Parse(Request.QueryString["primaryKey"]);
                _fileId          = Request.QueryString["fileId"];

                // saved in directory named virtual path + table names  : APPSETTING NEEDS to be between / and /
                _savePath = Page.ResolveUrl(FILE_UPLOAD_ROOT) + _tableName + "/";

                FilesDa   filesDA = new FilesDa();
                DataTable dt      = filesDA.GetRecordsByTableAndTablePK(_tableName, _tablePrimaryKey).Tables[0];

                // Contains Files
                if (dt.Rows.Count > 0)
                {
                    SetViewFilesMode();
                    UploadedFile userFile      = new UploadedFile();
                    int          firstRecordId = int.Parse(dt.Rows[0][UploadedFile.FileId].ToString());

                    if (!string.IsNullOrEmpty(_fileId))
                    {
                        _fileId = Security.CustomCryptoHelper.Decrypt(_fileId);
                        userFile.Get(int.Parse(_fileId));
                        //if (userFile.RecordCount == 0)
                        if (userFile.IsEmpty)
                        {
                            userFile.Get(firstRecordId);
                        }
                    }
                    else
                    {
                        _fileId = firstRecordId.ToString();
                        userFile.Get(firstRecordId);
                    }

                    string userFileId    = userFile[UploadedFile.FileId].ToString();
                    string userFileExt   = userFile[UploadedFile.FileExtension].ToString();
                    string userFileLabel = userFile[UploadedFile.FileLabel].ToString();


                    // Sets attribute general to all FILES
                    string pathToFile = GetPathToFile(userFileId, false);

                    MainImgTitle.Text   = userFileLabel;
                    FileId.Value        = userFileId.ToString();
                    FileExtension.Value = userFileExt;

                    // Only 1 contorl per holder
                    DocumentHolder.Controls.Clear();

                    if (IsDocumentType(IMG_EXTENSIONS, userFileExt))
                    {
                        DisplayImage(pathToFile, userFileExt);
                        JSpathToThumb = GetPathToFile(userFileId, true);// _savePath + userFileId + FileUploadForm.THUMB_EXTENSION + userFileExt;
                        JSpathToFile  = pathToFile;
                    }
                    else if (IsDocumentType(DOC_EXTENSIONS, userFileExt))
                    {
                        DisplayDocument(pathToFile, userFileExt);
                        JSpathToThumb = "GENERIC";
                    }
                }
                // else show controls to upload an image
                else
                {
                    SetUploadFilesMode();
                    JSpathToThumb = "";


                    if (Request.QueryString["fileLabel"] != null && Request.QueryString["fileLabel"].Length > 0)
                    {
                        FileLabel.Text = Request.QueryString["fileLabel"];
                    }
                }
            }
        }