getting header part of pdf document in asp.net from gridview data - export-to-pdf
// Sys.Application.add_init(function(){$create(Telerik.Web.UI.RadGrid,
{"ClientID":"radAccountSummary","ClientSettings":{"AllowAutoScrollOnDragDrop":true,"EnableRowHoverStyle":true,"ShouldCreateRows":true,"DataBinding":{},"Selecting":{"CellSelectionMode":0,"AllowRowSelect":true},"S
crolling":{},"Resizing":{},"ClientMessages":{},"KeyboardNavigationSettings":{"AllowActiveRowCycle":false,"EnableKeyboardShortcuts":true,"FocusKey":89,"InitInsertKey":73,"RebindKey":82,"ExitEditInsertModeKey":27,"Up
dateInsertItemKey":13,"DeleteActiveRow":127,"ExpandDetailTableKey":39,"CollapseDetailTableKey":37,"SaveChangesKey":85,"CancelChangesKey":67},"Animation":{},"Virtualization":{}},"Skin":"WebBlue","UniqueID":"rad
AccountSummary","_activeRowIndex":"","_controlToFocus":"","_currentPageIndex":0,"_defaultDateTimeFormat":"dd-MM-yyyy
HH:mm:ss","_editIndexes":"[]","_embeddedSkin":true,"_gridTableViewsData":"[{\"ClientID\":\"radAccountSummary_ctl00\",\"UniqueID\":\"radAccountSummary$ctl00\",\"PageSize\":10,\"PageCount\":1,\"EditMode\":\"EditFor
ms\",\"AllowPaging\":false,\"CurrentPageIndex\":0,\"VirtualItemCount\":0,\"AllowMultiColumnSorting\":false,\"AllowNaturalSort\":true,\"AllowFilteringByColumn\":false,\"PageButtonCount\":10,\"HasDetailTables\":false,\"Has
MultiHeaders\":false,\"CheckListWebServicePath\":\"\",\"GroupLoadMode\":\"Server\",\"PagerAlwaysVisible\":false,\"IsItemInserted\":false,\"clientDataKeyNames\":[],\"hasDetailItemTemplate\":false,\"_dataBindTemplates\":f
alse,\"_selectedItemStyle\":\"\",\"_selectedItemStyleClass\":\"rgSelectedRow\",\"_columnsData\":[{\"UniqueName\":\"TransactionDate\",\"Resizable\":true,\"Reorderable\":true,\"Selectable\":true,\"Groupable\":true,\"ColumnT
ype\":\"GridBoundColumn\",\"ColumnGroupName\":\"\",\"Editable\":true,\"DataTypeName\":\"System.String\",\"DataField\":\"TransactionDate\",\"Display\":true},{\"UniqueName\":\"InvoiceNumber\",\"Resizable\":true,\"Reorde
rable\":true,\"Selectable\":true,\"Groupable\":true,\"ColumnType\":\"GridBoundColumn\",\"ColumnGroupName\":\"\",\"Editable\":true,\"DataTypeName\":\"System.String\",\"DataField\":\"InvoiceNumber\",\"Display\":true},{\"Un
iqueName\":\"TranType\",\"Resizable\":true,\"Reorderable\":true,\"Selectable\":true,\"Groupable\":true,\"ColumnType\":\"GridBoundColumn\",\"ColumnGroupName\":\"\",\"Editable\":true,\"DataTypeName\":\"System.String\",\
"DataField\":\"TranType\",\"Display\":true},{\"UniqueName\":\"TransactionDescription\",\"Resizable\":true,\"Reorderable\":true,\"Selectable\":true,\"Groupable\":true,\"ColumnType\":\"GridBoundColumn\",\"ColumnGroupNam
e\":\"\",\"Editable\":true,\"DataTypeName\":\"System.String\",\"DataField\":\"TransactionDescription\",\"Display\":true},{\"UniqueName\":\"TemplateColumn\",\"Resizable\":true,\"Reorderable\":true,\"Selectable\":true,\"Groupa
ble\":true,\"ColumnType\":\"GridTemplateColumn\",\"ColumnGroupName\":\"\",\"Editable\":false,\"DataTypeName\":\"System.String\",\"DataField\":\"TransactionAmount\",\"Display\":true},{\"UniqueName\":\"Total_Fuel\",\"Re
sizable\":true,\"Reorderable\":true,\"Selectable\":true,\"Groupable\":true,\"ColumnType\":\"GridTemplateColumn\",\"ColumnGroupName\":\"\",\"Editable\":false,\"DataTypeName\":\"System.String\",\"DataField\":\"\",\"Display\"
:true}]}]","_masterClientID":"radAccountSummary_ctl00","_shouldFocusOnPage":false,"allowMultiRowSelection":false,"clientStateFieldID":"radAccountSummary_ClientState","expandItems":{}}, null, null,
$get("radAccountSummary"));}); //
Related
FIDO2 C++ based application using WebAuthn.dll for "YUBIKEY 5 NFC" (External authenticator) gives "The parameter is incorrect"
I am writing FIDO2 C++ based application using WebAuthn.dll for "YUBIKEY 5 NFC" (External authenticator) using the following WebAuthN APIs of Microsoft from the https://github.com/microsoft/webauthn/blob/master/webauthn.h I'm trying to Authenticate with the api WebAuthNAuthenticatorGetAssertion(). I get the error "The parameter is incorrect" HWND hWnd = GetForegroundWindow(); LPCWSTR pwszRpId = nullptr; std::string sClientData64 = {"type":"webauthn.get","challenge":"<< base64 Encoded challenge","crossOrigin":true}; WEBAUTHN_CLIENT_DATA oClientData_in = { WEBAUTHN_CLIENT_DATA_CURRENT_VERSION, static_cast<DWORD>(sClientData64.length()), (PBYTE)(sClientData64.data()), WEBAUTHN_HASH_ALGORITHM_SHA_256 }; WEBAUTHN_CREDENTIAL_EX webCredEx = { WEBAUTHN_CREDENTIAL_EX_CURRENT_VERSION, static_cast<DWORD>(CredentialId.length()), ((BYTE*)(CredentialId.c_str())), WEBAUTHN_CREDENTIAL_TYPE_PUBLIC_KEY, WEBAUTHN_CTAP_TRANSPORT_USB }; WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS webAuthNGetAssertionOptions = { WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_CURRENT_VERSION, // version timeOut, // time in milliseconds {0, NULL}, //WEBAUTHN_CREDENTIALS {0, NULL}, //WEBAUTHN_EXTENSIONS WEBAUTHN_AUTHENTICATOR_ATTACHMENT_ANY, // for Platform (Windows Hello) vs Cross platform authenticator (Yubikey) WEBAUTHN_USER_VERIFICATION_REQUIREMENT_ANY, // user Verification Required (preferred) 0, // dwFlags NULL, // as json data received it is null nullptr, //(FALSE) this is a pointer NULL, // pCancellationId pAllowCredentialList // dwversion = 4) allowlist is not null }; WEBAUTHN_ASSERTION* pWebAuthNAssertion = nullptr; // this is an output parameter, // on calling, I get a dialog popup saying " The parameter is incorrect." hResult = WebAuthNAuthenticatorGetAssertion(hWnd, pwszRpId &oClientData_in, &webAuthNAssertionOptions, &pWebAuthNAssertion); Please let me know, if any thing has to added in my code.
My guess is pAllowCredentialList in the webAuthNGetAssertionOptions is the culprit. Does it work with NULL instead? I have a similar very simple sample at https://github.com/aseigler/HelloSample/blob/master/hello/hello.cpp that worked last time I checked.
int8 parameter input for imgSessionSaveBufferEx()
I am trying to execute the imgSessionSaveBufferEx function: I would like to save an image into PNG format, what should I input as the parameter for Int8* file_name? imgSessionSaveBufferEx(sessionID, NULL, ______);
The sequence of attempts are below: imgSessionSaveBufferEx(sessionID, NULL, "test.png"); imgSessionSaveBufferEx(sessionID, NULL, reinterpret_cast<Int8*>("test.png")); // this is the answer, provided by Botje imgSessionSaveBufferEx(sessionID, NULL, reinterpret_cast<Int8*>(const_cast<char *>("test.png")));
Editing docx with openxml returns invalid memorystream
I created a DLL that takes a Word template, I have code that edits the document using openXML then the result is sent via memory stream to a web service where the documents is downloaded to the user. The issue is that the memory stream is sending is either the original template document without the updates OR sends the updated Word document XML format where the document is obviously corrupted. Here is the code: string strTemplate = AppDomain.CurrentDomain.BaseDirectory + "Report Template.docx"; WordprocessingDocument wdDocument; //stream the template byte[] fileBytes = File.ReadAllBytes(strTemplate); MemoryStream memstreamDocument = new MemoryStream(); memstreamDocument.Write(fileBytes, 0, (int)fileBytes.Length); wdDocument = WordprocessingDocument.Open(memstreamDocument, true); //CODE TO UPDATE TEMPLATE //Save entire document wdDocument.MainDocumentPart.Document.Save(); After saving the document, if using the following code the memory stream returns the original template without any updates to the document: return memstreamDocument; If using the following code the memory stream returns the openXML data with the updates but the document is corrupted: MemoryStream memstreamUpdatedDocument = new MemoryStream(); Stream streamDocument = wdDocument.MainDocumentPart.GetStream(); streamDocument.CopyTo(memstreamUpdatedDocument); return memstreamUpdatedDocument; Here is my code in the web service which works fine: HttpResponse response = HttpContext.Current.Response; MemoryStream stream = GR.GetReport("", intReportID, Culture, ConnectionString, false); response.Clear(); response.ClearHeaders(); response.ClearContent(); response.AddHeader("content-disposition", "attachment; filename=\"" + "Report_" + intReportID+ ".docx\""); response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1"); stream.Position = 0; stream.CopyTo(response.OutputStream); response.End(); return response;
After reviewing the supplied code I have provided a modified code snippet that should fit your needs of returning a modified MemoryStream from a file template using the WordprocessingDocument class by OpenXML. Your web service code snippet provided should work as is. // file path of template string strTemplate = AppDomain.CurrentDomain.BaseDirectory + "Report Template.docx"; // create FileStream to read from template FileStream fsTemplate = new FileStream(strTemplate, FileMode.Open, FileAccess.Read); // create MemoryStream to copy template into and modify as needed MemoryStream msDocument = new MemoryStream(); // copy template FileStream into document MemoryStream fsTemplate.CopyTo(msDocument); // close the template FileStream as it is no longer necessary fsTemplate.Close(); // reset cursor position of document MemoryStream back to top // before modifying msDocument.Position = 0; // create WordProcessingDocument using the document MemoryStream using (WordprocessingDocument wdDocument = WordprocessingDocument.Open(msDocument, true)) { //Access the main Workbook part, which contains all references. MainDocumentPart mainPart = wdDocument.MainDocumentPart; /* ... CODE TO UPDATE TEMPLATE ... */ // save modification to main document part wdDocument.MainDocumentPart.Document.Save(); // close wdDocument as it is no longer needed wdDocument.Close(); } // reset cursor position of document MemoryStream back to top msDocument.Position = 0; // return memory stream as promised return msDocument;
Insert raw file data into BLOB ("OLE Object") field of Access table using ADO
I am trying to insert a file into MS Access database, into a field of OLE Object type. I am using C++ and ADO. Currently I get error Invalid pointer error. I think that my problem is mishandling variants since this is the first time I use them. I am learning from this code example but have problem understanding how to insert file from disk into variant. They read it from database, and copied it into new record so the part where I read file from disk and then insert it into variant is missing. I am firing off my code in GUI when menu item is selected. Database has one table named test with fields ID which is primary key and field which is of OLE Object type. After searching online I have found nothing that can help me. Here is smallest code snippet possible that illustrates the problem ( error checking is minimal): wchar_t *bstrConnect = L"Provider=Microsoft.ACE.OLEDB.12.0; \ Data Source = C:\\Users\\Smiljkovic85\\Desktop\\OLE.accdb"; try { HRESULT hr = CoInitialize(NULL); // connection ADODB::_ConnectionPtr pConn(L"ADODB.Connection"); // recordset ADODB::_RecordsetPtr pRS(L"ADODB.Recordset"); // connect to DB hr = pConn->Open(bstrConnect, L"admin", L"", ADODB::adConnectUnspecified); // open file std::ifstream in(L"C:\\Users\\Smiljkovic85\\Desktop\\file.pdf", std::ios::ate | std::ios::binary); // get file size int fileSize = in.tellg(); // here I tried to adapt code from the example linked above pRS->Open(L"test", _variant_t((IDispatch*)pConn, true), ADODB::adOpenKeyset, ADODB::adLockOptimistic, ADODB::adCmdTable); // add new record pRS->AddNew(); // copy pasted _variant_t varChunk; SAFEARRAY FAR *psa; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; // modify to our file size rgsabound[0].cElements = fileSize; psa = SafeArrayCreate(VT_UI1, 1, rgsabound); //=================== try to add file into variant char *chData = (char *)psa->pvData; chData = new char[fileSize]; in.read(chData, fileSize); /* ============= I have even tried the following : char *chData = new char[fileSize]; in.read(chData, fileSize); BYTE* pData; SafeArrayAccessData(psa, (void **)&pData); memcpy(pData, chData, fileSize); SafeArrayUnaccessData(psa); ===============*/ //================================================= // Assign the Safe array to a variant. varChunk.vt = VT_ARRAY | VT_UI1; varChunk.parray = psa; pRS->Fields->GetItem(L"field")->AppendChunk(varChunk); // add this record into DB pRS->Update(); // cleanup delete[] chData; in.close(); pRS->Close(); pConn->Close(); CoUninitialize(); } catch (_com_error e) { MessageBox(hWnd, (LPWSTR)e.Description(), L"", 0); } Can you help me to modify this code snippet so I can insert file into variant? EDIT: I have searched here for help and two posts that gave me an idea. Still none of my solutions work. You can see them in the above code snippet, in the comments. What I get now, is the following error: a problem occurred while microsoft access was communicating with the ole server or activex control in MS Access. I have searched online for solution but had no luck, every link claims it has to do with access and not with the code. Please help...
Since you are already using ADODB.Connection and ADODB.Recordset objects you should be able to use a binary ADODB.Stream object to manipulate the file contents with .LoadFromFile to fill the Stream with the file contents, and .Read to pull it back out of the Stream and store it in the database field. Unfortunately I cannot offer a C++ example, but in VBA the code would be: Dim con As ADODB.Connection, rst As ADODB.Recordset, strm As ADODB.Stream Set con = New ADODB.Connection con.Open _ "Provider=Microsoft.ACE.OLEDB.12.0;" & _ "Data Source=C:\Users\Public\Database1.accdb" Set rst = New ADODB.Recordset rst.Open "test", con, adOpenKeyset, adLockOptimistic, adCmdTable Set strm = New ADODB.Stream strm.Type = adTypeBinary strm.Open strm.LoadFromFile "C:\Users\Gord\Desktop\test.pdf" rst.AddNew strm.Position = 0 rst.Fields("FileData").Value = strm.Read rst.Update rst.Close Set rst = Nothing con.Close Set con = Nothing strm.Close Set strm = Nothing
Get specific Outlook attachment (OLE Automation C++)
I can't get a specific Outlook (2013) email attachment. I'm working on a little project to learn about MS Office Automation using C++ and I'm testing Outlook automation. In partcular I would like to download a specific email attachment but I can't access to that item. For example, if I have in my inbox an email with 4 attachments I want get the 2nd one. I tried with this code but the HRESULT returned value from the AutoWrap() method is always not valid: VARIANT result; VariantInit(&result); CComPtr<IDispatch> pAttachments; // email attachments HRESULT hRes = AutoWrap(DISPATCH_PROPERTYGET, &result, pOfficeItem, L"Attachments", 0); if (!result.pdispVal || FAILED(hRes)) return EditorError; // EditorError is an Enum pAttachments = result.pdispVal; VariantInit(&result); hRes = AutoWrap(DISPATCH_PROPERTYGET, &result, pAttachments, L"Count", 0); if (FAILED(hRes)) return EditorError; int aNumber = result.iVal; // it works, if i have an email with 4 attachments then aNumber is 4 if(aNumber > 0){ VARIANT attachmentIndex; attachmentIndex.vt = VT_I4; attachmentIndex.llVal = 0; // I want the 1st attachment VariantInit(&result); CComPtr<IDispatch> pAttachmentItem; hRes = AutoWrap(DISPATCH_PROPERTYGET, &result, pAttachments, L"Item", 1, attachmentIndex); if (FAILED(hRes)) return EditorError; // here it returns EditorError } ... DO SOMETHING ... where AutoWrap() is the method recommended by MS in order to interact with the MS Application (http://www.codeproject.com/Articles/34998/MS-Office-OLE-Automation-Using-C).
Remarks: The Index property is only valid during the current session and can change as objects are added to and deleted from the collection. The first object in the collection has an Index value of 1.