Unable to find Resource using RT_RCDATA - resources

I have an application where I have wave files embedded as resources. The wave files are added as Custom Resources under the type "WAVE".
Now, I am trying to retrieve the embedded wave files using FindResource() and LoadResource().
Now here's the problem: I am able to find the bitmap resource using FindResource() but NOT the Wave resources. I am using RT_RCDATA as ResourceType. Here's the code snippet:
// Load the .EXE file that contains the dialog box you want to copy.
hExe = LoadLibrary(TEXT("C:\\ExternalResource.exe"));
if (hExe == NULL)
{
//ErrorHandler(TEXT("Could not load exe."));
return 0;
}
// Locate the Testsong200 resource in the .EXE file.
//hRes = FindResource(hExe, MAKEINTRESOURCE(104), RT_BITMAP);
hRes = FindResource(hExe, MAKEINTRESOURCE(105), RT_RCDATA);
if (hRes == NULL)
{
//ErrorHandler(TEXT("Could not locate dialog box."));
return 0;
}
The hRes returns NULL when I use RT_RCDATA.
Any pointers in the right direction will make my day :)
regards,
andy.
P.S I tried to upload the screenshot but realised that I need to have 10 rep points to upload one :(

OK, Got it.
I need to use FindResource in the following way:
hRes = FindResource(hExe, MAKEINTRESOURCE(105), _T("WAVE"));
regards,
andy

Related

How does one access an Extension to a table in Acumatica Business Logic

Apologies if this question has been answered elsewhere, I have had trouble finding any resources on this.
The scenario is this. I have created a custom field in the Tax Preferences screen called Usrapikey.
This value holds an api key for a call that gets done in some custom business logic.
The custom business logic however occurs on the Taxes screen.
So within the event handler I need to access that API key value from the other screen. I have tried instantiating graphs and using linq and bql but to no avail.
below is what I have currently and my error is: No overload for method 'GetExtension' takes 1 arguments
If I am going about this the wrong way please let me know if there is a more civilized way to do this
protected virtual void _(Events.FieldUpdated<TaxRev, TaxRev.startDate> e)
{
var setup = PXGraph.CreateInstance<TXSetupMaint>();
var TXSetupEX = setup.GetExtension<PX.Objects.TX.TXSetupExt>(setup);
var rateObj = GetValues(e.Row.TaxID, TXSetupEX.Usrapikey);
decimal rate;
var tryRate = (Decimal.TryParse(rateObj.rate.combined_rate, out rate));
row.TaxRate = (decimal)rate * (decimal)100;
row.TaxBucketID = 1;
}
Many Thanks!
Well, acumatica support got back. It seems if you want to access the base page use:
TXSetup txsetup = PXSetup<TXSetup>.Select(Base);
To get the extension use:
TXSetupExt rowExt = PXCache<TXSetup>.GetExtension<TXSetupExt>(txsetup);
Then you can access the extension fields like so:
var foo = rowExt.Usrfield;

Azure FHIR: Get RawResource in Plain Text

I've just started my research on the "Azure FHIR SQL Server Version".
I had some issues trying to get the Json Resource in plain text, since It is stored compressed in the database (as shown in the following lines):
select r.RawResource from dbo.Resource r where r.IsHistory=0 and r.IsDeleted=0;
RAWRESOURCE
0x1F8B080000000000000A8492CB4EC2501086E7519AAE344122F7E04A4274618C90C8CEB8282D60136E2985A08477F79B39A71513D034E77466CECC3FFF5C0E124A2613D9C84AB64831F2483E65CD3F943BCE00EB4C22594A2A5FFC73FE2BB4502A9C5412EF579786B4898AA4234DEE1BB99531783152137B225DA431D6485A481DF408FB546AC8131FD9F0B839FA9E5BB10FDC1B64CDBD4572F966782C3999D9153F9463C949DF94E994A33E1AF366483BFCE7E014F5D561D4E2AB733A76B7398AF56E68111528D2CE47E4A069B4BE2D795D94487D7053EB538C3D300E01D608CEAABF4A0FCDD5A71C527B71CCFE8B0E3D1BAD74CE8999C1E2A4AA0D33D31E4DBC3564821F362765573953F71575D7E49A1C4D3EED429BBBEBBB781E53A50886F30B982F641C59C7356F1F2DB3ED5AC93DF32A62AB25FBCB99A6F8EEFFC8129CE409E4D17BFFCC2CE1737B5D7458F3B80E3B1CED790FEC2AF14F44ECFCA60432B49D4A2CCB83E7159035C352B50D69A10FE0A8B10DEB63319F18949C6A1CD36734ADDAD5B126DEEDF1DC7AA35BFADB2F00BDE3BDB5475BDBE2ACC41B1AC3ADAFF428DF000000FFFF
I tried different ways to get it, however no one was successful.
select cast(r.RawResource as varchar(max)) VarcharResource,
CONVERT(varchar(max), r.RawResource, 0) VarcharResource2
from dbo.Resource r where r.IsHistory=0 and r.IsDeleted=0;
VarcharResource2
‹ „’ËNÂP†çQš®4A""÷àJBtaŒÈθ(-`n)… „w÷›9§Ð4çtfÎÌ?ÿ\J&ÙÈJ¶H1òH>eÍ?”;Î ëL""YJ*_üsþ+´P*œTïW—†´‰Š¤#M1x1R{""]¤1ÖHZHôûTjÈÙð¸9úž[±ÜdͽErùfx,9™Ù?”cÉIߔ锣>ófH;üçàõÕaÔâ«s:v·9Šõnh(ÒÎGä i´¾-y]”H}pSëSŒ=0ÖΪ¿JÍÕ§R{qÌþ‹=­tΉ™Á⤪3ÓM¼5d‚6'eW9S÷u×äšM>íB›»ë»xS¥†ó˜/dYÇ5o-³íZÉ=ó*b«%ûË™¦øîÿÈœä äÑ{ÿÌ,ás{]tXó¸;íyì*ñODìü¦2´J,˃ç5ÃRµi¡à¨±ëc1Ÿ”œjÓg4­ÚÕ±&ÞíñÜz£[úÛ/ ½ã½µG[Ûâ¬Äí¯ô(ß ÿÿ
Anybody knows the correct way to get back the Json in plain text?
Thanks
The resources are Gzipped, so something like:
string rawResource;
using (rawResourceStream)
using (var gzipStream = new GZipStream(rawResourceStream, CompressionMode.Decompress))
using (var reader = new StreamReader(gzipStream, ResourceEncoding))
{
rawResource = await reader.ReadToEndAsync();
}

How do I determine the time needed to open the big file (20MB)?

We are working on Universal Windows Apps in which we are opening the files (whose size is 20MB) using below code.
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.FileTypeFilter.Add(".abc");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file == null) return false;
FlowSheetFilePath = file.Path;
LaunchQuerySupportStatus status = await Launcher.QueryFileSupportAsync(file);
if (status == LaunchQuerySupportStatus.Available)
{
bool didLaunch = await Launcher.LaunchFileAsync(file);
if (didLaunch)
{
}
}
In the above code, Is there any way to determine how much time is needed to completely open the file whose size is around 20MB?
It's not possible. Note that this will depend not only on device configuration/type but ola CPU overload and so on.
If your app read/processes the file you may implement some kind of ProgressBar that will indicate how much work is already done (with implementation of IProgress<>) and how much is left, however that also won't help you with determination of time - you can think of estimating the time left basing on that what is already done, but this is only estimation and will surely change over time. But this won't also help you with Launcher.LaunchFileAsync(file).

How to add a Calculated field to AllContentType?

Today, I'm having a problem is after I had created a Calculated field. It seems there is no way to add AllContentTypes. And the DefaultView, maybe I can handle this. And I also saw this method:
spList.Fields.AddFieldAsXml(spFieldUser.SchemaXml, True, SPAddFieldOptions.AddToAllContentTypes);
But in this case, I'm not sure I can use it or not. Because my code is:
//SPField tempSPField = spList.Fields.CreateNewField(createSPColumnObject.ColumnType, createSPColumnObject.ColumnName);//We can not use this code line for creating Calculated (there is no constructor for this)
SPFieldCollection collFields = spList.Fields;
string strSPFieldCalculatedName = collFields.Add(createSPColumnObject.ColumnName, SPFieldType.Calculated, false);
if (createSPColumnObject.IsAddedToDefaultView)
{
SPView spView = spList.DefaultView;
spView.ViewFields.Add(strSPFieldCalculatedName);
spView.Update();
}
SPFieldCalculated spFieldCalculated = null;
//
spFieldCalculated = (SPFieldCalculated)collFields[createSPColumnObject.ColumnName];
spFieldCalculated.ShowInDisplayForm = true;
//spFieldCalculated.ShowInEditForm = true;
spFieldCalculated.ShowInListSettings = true;
//spFieldCalculated.ShowInNewForm = true;
spFieldCalculated.ShowInViewForms = true;
//
spFieldCalculated.Description = createSPColumnObject.ColumnDescription;
spFieldCalculated.Formula = string.Format(#"={0}",createSPColumnObject.CalcFormula);
spFieldCalculated.Update();
//spList.Fields.AddFieldAsXml(spFieldCalculated.SchemaXml, createSPColumnObject.IsAddedToDefaultView, SPAddFieldOptions.AddToAllContentTypes);// also use this code line because we will get an exception with a duplicate column ID.
spFieldCalculated.OutputType = SPFieldType.Text;
spList.Update();
I totally created a Calculated column but how can I add it to allcontent types ? everybody could help me out this ? BTW, to the DefaultView, I did like the above is right ? Could eveybody let me know this ?
I just worry about everybody get misunderstanding ? Or review with missing code. So could everybody please to take a look on my code clearly ? Thanks all.
Many thanks, :)
Standley Nguyen
I'm not sure if i fully understand what you are trying to do however i may be able to shed some light on some parts of what you are trying to do.
When you create your field does it then appear in your site actions -> site settings -> Site columns. If so you have created this correctly. If it doesn't there are hundreds of examples of how to do this if you search google.
Once you have your field create you then need to consider which content types you want to add it to. Once you have these content types you then have to add something called a field link to the Content type.
This isn't my code i have picked it off the web but this should do what you require.
SPContentType ct = web.ContentTypes[contentType];
ct.FieldLinks.Add(new SPFieldLink(field));
ct.Update();
Cheers
Truez

Sharepoint: How to add file to without changing version?

I need to add new version of the file to SPFileCollection without changing version (it is a system update of the content of pdf file)
UpdateOverwriteVersion allows me to change metadata but is there a way to change content (bytes) of the file?
WORKAROUND:
Ok, as Stefan found out, there is no satisfactory solution to this.
I found two workarounds:
1.
(Be aware that turning off the version control could lead to wrong behavior, if there are people working on that list... – Stefan)
oFile = oWeb.GetFile(url);
oFile.Item.ListItems.List.EnableVersioning = false;
oFile.Item.ListItems.List.Update();
oFolder.Files.Add(oFile.Name, aBytes, fileProperties, true);
oFile.Item.ListItems.List.EnableVersioning = true;
oFile.Item.ListItems.List.Update();
2.
oFile = oWeb.GetFile(sAdres);
int iFileVersion = oFile.UIVersion;
oFolder.Files.Add(oFile.Name, aBytes, fileProperties, true);
oFileVersion = oFile.Versions.GetVersionFromID(iFileVersion);
if (null != oFileVersion && !oFileVersion.IsCurrentVersion)
{
oFileVersion.Delete();
}
Why don't you use SystemUpdate(false)
http://msdn.microsoft.com/en-us/library/ms481195.aspx
You can load the SPFile object and then call SPFile.SaveBinary(Stream, SPFileSaveBinaryParameters) method to update it's content.
With the CreateVersion property of the SFileSaveBinaryParameters you can specify whether a new version should be created or not.
[...] this is by design. As far as I know , there is no other solutions on it.
A quote from a moderator at Microsoft TechNet forum.

Resources