i using jqgrid 4.3.3
. have code jqgrid below
function examinationdocumentgridlist(examinationid) { var url1 = '../pimsrecords/getexamdocument?examinationid=' + examinationid; $("#personexaminationdoclist").jqgrid({ url: url1, datatype: 'json', mtype: 'post', colnames: ['rowid', 'sid', 'pid', 'document name', 'document no', 'validated by', 'validated date', '', '', ''], colmodel: [ { name: 'rowid', index: 'rowid', hidden: true, width: 65 }, { name: 'personexamdocid', index: 'personexamdocid', hidden: true, width: 20, align: 'left' }, { name: 'examinationid', index: 'examinationid', hidden: true, width: 65 }, { name: 'personexamname', index: 'personexamname', width: 150, align: 'left' }, { name: 'personexamno', index: 'personexamno', width: 90, align: 'center' }, { name: 'validatedby', index: 'validatedby', width: 150, align: 'center' }, { name: 'validateddate', index: 'validateddate', sortable: false, width: 100, align: 'center' }, { name: 'fileextension', index: 'fileextension', hidden: true, sortable: false, width: 70, align: 'center' }, { name: 'imagereportid', index: 'imagereportid', hidden: true, sortable: false, width: 70, align: 'center' }, { name: 'imagefilename', index: 'imagefilename', hidden: true, sortable: false, width: 70, align: 'center' } ], pager: $('#personexaminationdocpager'), rownum: 3, rowlist: [3, 6, 12], sortname: 'validateddate', sortorder: "desc", viewrecords: true, height: '100%', onselectrow: function (id) { var objrowdata = jquery("#personexaminationdoclist").getrowdata(id); var personexamname = objrowdata.personexamname; var personexamno = objrowdata.personexamno; var validatedby = objrowdata.validatedby; var validateddate = objrowdata.validateddate; var docid = objrowdata.imagereportid; var docname = objrowdata.imagefilename; var fileextension = objrowdata.fileextension; $("#hidexamdocimagereportid").val(docid); $("#hidexamdocimagefilename").val(docname); $("#personexamname").val(personexamname); $("#personexamno").val(personexamno); $("#divsignatoryid #hrhead option:contains(" + validatedby + ")").attr('selected', 'selected'); $("#validateddate").val(validateddate); var url = '../pimsrecords/_examinationdoc/' + objrowdata.personexamdocid; var pid = objrowdata.personexamdocid; $("#hidentrypersonexamdocid").val(pid); viewpartialexamdocs(url, "partialexamdoc"); }, loadcomplete: function () { /*gets ids of grid */ var ids = jquery("#personexaminationdoclist").getdataids(); /*gets number of rows of grid */ var len = ids.length, newline; if (len < 3) { /*make blank newlinedata */ /*calls function add row data */ addnewrowtogridlistofdocument(len, '#personexaminationdoclist'); } } }); }
for function
function viewpartialexamdocs(url, partialdocumentpreview) { $.ajax({ type: "post", url: url, data: {}, success: function (response) { $("#" + partialdocumentpreview + "").html(response); var fileid = $("#hidexamdocimagereportid").val(); var filename = $("#hidexamdocimagefilename").val(); fileextension = filename.substr(filename.lastindexof('.') + 1, 4); if (fileextension == 'pdf') { $("#empexamimgfirstpreview").hide(); $("#empexamiframefirstpreview").show(); var varsrc = "../uploaddownload/_viewpdf?&fid=" + fileid + "&filename=" + filename; $("#empexamdocframeid").attr('src', varsrc); $("#examdocpreviewframeid").attr('src', varsrc); } else { $("#empexamimgfirstpreview").show(); $("#empexamiframefirstpreview").hide(); } }, error: function (response) { alert("error" + response); }, datatype: "html" }); }
this controller
[httppost] public actionresult _examinationdoc(int id) { viewdata["examinationdoc"] = _or.getpersonexamdoc(id); return partialview("_examinationdoc", viewdata["examinationdoc"]); }
here data controller get
public personexaminationdocument getpersonexamdoc(int id) { var examdoc = (from ed in db.personexaminationdocuments ed.personexamdocid == id select ed).singleordefault(); return examdoc; }
this code viewing picture
@model pims.models.personexaminationdocument <center> <fieldset style="width: 160px; height: 250px"> <legend style="text-align: left; font-style: normal; font-weight: bold; font-family: arial; font-size: 12px;">document preview</legend> <div id="empexamimgfirstpreview"> @if (model != null) { if (model.imagereportid != null) { <img alt="examdoc" id="examdocimg" height="220px" width="150px" src="@url.action("download", "uploaddownload", new { @id = model.imagereportid, @fname = model.imagefilename })" /> } else { <img alt="examdoc" id="examdocimg" height="220px" width="150px" src="@url.content("~/content/images/document_preview.png")"/> } } else { <img alt="examdoc" id="examdocimg" height="220px" width="150px" src="@url.content("~/content/images/document_preview.png")"/> } </div> <div id="empexamiframefirstpreview" runat="server" style="display: none"> <iframe id="empexamdocframeid" style="width: 150px; height: 220px;"></iframe> </div> </fieldset> </center> <input id="hidimageid" type="hidden" /> <input id="hidfnameid" type="hidden" /> <input id="hidexamuploadeddoc" type="hidden" /> <input id="hidexamdocsextensionid" type="hidden" />
this code download picture viewing , error
public actionresult download(guid id, string fname) { filetransferserviceclient client = new filetransferserviceclient(); downloadrequest dr = new downloadrequest(); remotefileinfo rmi = new remotefileinfo(); stream stream = null; string pid = id.tostring(); string userkey = "gheoai6bfzwskyuxx2ivq4+pj7alwbzwf55dzvy/23brhafvdvj7mg"; string passkey = "llahwegn8zds7mizyzzj+emzlkuxkveyxlvgayjubvtu8sw6wkxy2g"; client.open(); rmi = client.downloadfile(ref pid, ref fname, ref passkey, ref userkey); -------- here error why? stream = rmi.filebytestream; memorystream writestream = new memorystream(); int32 chunksize = 2048; byte[] buffer = new byte[chunksize]; { int32 bytesread = stream.read(buffer, 0, chunksize); if (bytesread == 0) { break; } writestream.write(buffer, 0, bytesread); } while (true); client.close(); string ext1 = getextension(fname); string ext = ext1.tolower(); string contenttype = "image/png"; if ((ext == "jpeg") || (ext == "png")) { contenttype = "image/png"; } else if ((ext == "gif")) { contenttype = "image/gif"; } else if (ext == "txt") { contenttype = "text/html"; } else if ((ext == "doc") || (ext == "docx")) { contenttype = "application/msword"; } else if ((ext == "ppt") || (ext == "pptx")) { contenttype = "application/vnd.ms-powerpoint"; } else if (ext == "pdf") { contenttype = "application/pdf"; } else if ((ext == "mp3")) { contenttype = "audio/mpeg"; } else if (ext == "mp4") { contenttype = "video/mp4"; } else if (ext == "flv") { contenttype = "video/x-flv"; } else if (ext == "wmv") { contenttype = "application/x-ms-wmv"; } var imagebytes = writestream.toarray(); if (imagebytes == null) { return new filepathresult("~/content/images/btn_mtops_pic.png", "image/png"); } else { filecontentresult file = new filecontentresult(imagebytes, contenttype); response.appendheader("content-disposition", "attachment; filename=" + fname); return file; } }
and got tfs http://192.168.120.11:600/ftservices.svc/basic
this error get. know this?. please help. thanks.
Comments
Post a Comment