Esempio n. 1
0
        private void DownloadDocumentFile()
        {
            PODocumentUploadDL _fileStatus = new PODocumentUploadDL();

            _fileStatus.GetWorkOrderDocumentByWorkOrderDocumentID(Convert.ToInt32(hfFileID.Value.ToString()));

            string path = MapPath(_fileStatus.FilePathandFileName);

            byte[] bts = System.IO.File.ReadAllBytes(path);

            Response.Clear();
            Response.ClearHeaders();

            Response.AddHeader("Content-Type", "Application/octet-stream");
            Response.AddHeader("Content-Length", bts.Length.ToString());
            Response.AddHeader("Content-Disposition", "attachment; filename=" + _fileStatus.FileName);
            Response.BinaryWrite(bts);
            Response.Flush();
            Response.End();



            //WebClient client = new WebClient();
            //client.Credentials = CredentialCache.DefaultCredentials;
            //client.DownloadFileAsync(new Uri(url), @"c:\temp\image35.png");
            ////object documentFile = _fileStatus.DocumentFile;
            ////byte[] bytFile = (byte[])documentFile;

            ////Response.ContentType = "application/vnd.ms-word";
            ////Response.AppendHeader("Content-Disposition", "inline;filename=" + _clientFileStatus.DocumentFileName);
            ////Response.BinaryWrite(bytFile);
            ////Response.End();
        }
Esempio n. 2
0
        protected void gvWorkOrderDocument_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Cells[1].Visible = false;
                    e.Row.Cells[3].Visible = false;

                    // Set the Serial Number
                    Label lblSerial = (Label)e.Row.FindControl("lblSerial");
                    lblSerial.Text =
                        ((gvWorkOrderDocument.PageIndex * gvWorkOrderDocument.PageSize) + e.Row.RowIndex + 1).ToString();



                    PODocumentUploadDL _fileStatus = new PODocumentUploadDL();

                    _fileStatus.GetWorkOrderDocumentByWorkOrderDocumentID(Convert.ToInt32(e.Row.Cells[1].Text));

                    string path = MapPath(_fileStatus.FilePathandFileName);
                    //byte[] bts = System.IO.File.ReadAllBytes(path);

                    //Response.Clear();
                    //Response.ClearHeaders();

                    //Response.AddHeader("Content-Type", "Application/octet-stream");
                    //Response.AddHeader("Content-Length", bts.Length.ToString());
                    //Response.AddHeader("Content-Disposition", "attachment; filename=" + _fileStatus.FileName);
                    //Response.BinaryWrite(bts);
                    //Response.Flush();
                    //Response.End();



                    HyperLink hlDocumentDownload = (HyperLink)e.Row.FindControl("hlDocumentDownload");
                    hlDocumentDownload.NavigateUrl = "~\\" + _fileStatus.FilePathandFileName;
                }
                else if (e.Row.RowType == DataControlRowType.Header)
                {
                    // Hide Column Headers
                    e.Row.Cells[1].Visible = false;
                    e.Row.Cells[3].Visible = false;
                }
                else if (e.Row.RowType == DataControlRowType.Footer)
                {
                    e.Row.Cells[1].Visible = false;
                    e.Row.Cells[3].Visible = false;
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("DocumentUpload.aspx", "", "gvWorkOrderDocument_RowDataBound", ex.Message.ToString(), new ACEConnection());
                throw;
            }
        }