Do you know how I can set UNB in EDIFACT?
I have a CSV input file:
VRD1;100;200;0;0;L
And the output should be:
UNA:+.? '
UNB+UNOA:2+100:14+200:14+200305:0704+00000000000000++AAA'
UNH+1+INVRPT:D:96A:UN:EAN005'
BGM+10::9+20200305070403+9
I have to map the second and third fields to UNB.
I appreciate any help in this regard. Thank you in advance.
You should be able to do this using the EdiOverride message context properties. You can find them in the Microsoft.BizTalk.Edi.BaseArtifacts assembly found in the BizTalk Server installation folder.
For instance, in an orchestration, you can do this:
EdifactMessage(EdiOverride.OverrideEDIHeader) = true;
EdifactMessage(EdiOverride.UNB2_1) = xpath(CsvMessage, ...); // 100
EdifactMessage(EdiOverride.UNB3_1) = xpath(CsvMessage, ...); // 200
Add a correlation set with the same properties to your send shape.
If you want to set them in a pipeline, use the property namespace http://schemas.microsoft.com/BizTalk/2006/edi-properties.
Related
I'm trying to use a script that loads in a point layer from CSV. The code that I used is:
uri = "file:///some_path/PyQGIS/Some.csv?delimiter={}&xField={}&yField={}".format(os.getcwd(), ";", "X", "Y")
vlayer = QgsVectorLayer(uri, "Name", "delimitedtext")
QgsProject.instance().addMapLayer(vlayer)
The structure of the .csv file is as follows:
SomeValue ----- X ----- Y
Hereby, the coordinates are put according to Amersfoort (EPSG:4289) e.g.: X = 213404, Y = 500846. When trying to load this in manually, everything is going fine. However in the script, it does not seem to work. To clarify: The delimiter used is a ;
Thanks in advance.
You can specify the projection of your data set by adding &crs=epsg:4723 to the URI definition. So your case becomes:
uri = "file:///some_path/PyQGIS/Some.csv?delimiter={}&crs=epsg:4289&xField={}&yField={}".format(os.getcwd(), ";", "X", "Y")
vlayer = QgsVectorLayer(uri, "Name", "delimitedtext")
QgsProject.instance().addMapLayer(vlayer)
The answer to this is issue has been solved by removing the "os.getcwd()" part of the code. Hope this will help anyone with similar issues.
I am currently porting an UWP application from C++/CX to C++/WinRT. I encountered a safe_cast<Platform::IBoxArray<byte>^>(data) where data is of type Windows::Foundation::IInspectable ^.
I know that the safe_cast is represented by the as<T> method, and I know there are functions for boxing (winrt::box_value) and unboxing (winrt::unbox_value) in WinRT/C++.
However, I need to know the equivalent of Platform::IBoxArray in order to perform the cast (QueryInterface). According to https://learn.microsoft.com/de-de/cpp/cppcx/platform-iboxarray-interface?view=vs-2017, IBoxArray is the C++/CX equivalent of Windows::Foundation::IReferenceArray, but there is no winrt::Windows::Foundation::IReferenceArray...
Update for nackground: What I am trying to achieve is retrieving the view transform attached by the HoloLens to every Media Foundation sample from its camera. My code is based on https://github.com/Microsoft/HoloLensForCV, and I got really everything working except for this last step. The problem is located around this piece of code:
static const GUID MF_EXTENSION_VIEW_TRANSFORM = {
0x4e251fa4, 0x830f, 0x4770, 0x85, 0x9a, 0x4b, 0x8d, 0x99, 0xaa, 0x80, 0x9b
};
// ...
// In the event handler, which receives const winrt::Windows::Media::Capture::Frames::MediaFrameReader& sender:
auto frame = sender.TryAcquireLatestFrame();
// ...
if (frame.Properties().HasKey(MF_EXTENSION_VIEW_TRANSFORM)) {
auto /* IInspectable */ userData = frame.Properties().Lookup(MF_EXTENSION_VIEW_TRANSFORM);
// Now I would have to do the following:
// auto userBytes = safe_cast<Platform::IBoxArray<Byte> ^>(userData)->Value;
//viewTransform = *reinterpret_cast<float4x4 *>(userBytes.Data);
}
I'm also working on porting some code from HoloLensForCV to C++/WinRT. I came up with the following solution for a very similar case (but not the exact same line of code you ask about):
auto user_data = source.Info().Properties().Lookup(c_MF_MT_USER_DATA); // type documented as 'array of bytes'
auto source_name = user_data.as<Windows::Foundation::IReferenceArray<std::uint8_t>>(); // Trial and error to get the right specialization of IReferenceArray
winrt::com_array<std::uint8_t> arr;
source_name.GetUInt8Array(arr);
winrt::hstring source_name_str{ reinterpret_cast<wchar_t*>(arr.data()) };
Specifically, you can replace the safe_cast with .as<Windows::Foundation::IReferenceArray<std::uint8_t> for a boxed array of bytes. Then, I suspect doing the same cast as me (except to float4x4* instead of wchar_t*) will work for you.
The /ZW flag is not required for my example above.
I can't believe that actually worked, but using information from https://learn.microsoft.com/de-de/windows/uwp/cpp-and-winrt-apis/interop-winrt-cx, I came up with the following solution:
Enable "Consume Windows Runtime Extension" via /ZW and use the following conversion:
auto abi = reinterpret_cast<Platform::Object ^>(winrt::get_abi(userData));
auto userBytes = safe_cast<Platform::IBoxArray<byte> ^>(abi)->Value;
viewTransform = *reinterpret_cast<float4x4 *>(userBytes->Data);
Unfortunately, the solution has the drawback of generating
warning C4447: 'main' signature found without threading model. Consider using 'int main(Platform::Array^ args)'.
But for now, I can live with it ...
I'm trying to create an SSIS package dynamically using DTS Runtime classes.
I'm trying to create a foreach loop using "Foreach From Variable Enumerator", where my variable contains an ArrayList with the necessary collection.
I'm unable to find a way through which i can set the variable (under enumerator configuration, as seen in VS) which will hold the collection for looping.
I'm not finding any options in forEachLoop.ForEachEnumerator. Nor am I able to cast forEachEnumeratorHost.InnerObject to an enumerator I want. I found on MSDN a class Microsoft.SqlServer.Dts.Runtime.Enumerators.FromVar.ForEachFromVarEnumerator. But I'm not able to find the FromVar class in Enumerators. Am i missing something grave?
Has anyone else done this? I find it difficult to believe that something which can be done so easily through Visual Studio UI, cannot be done programmatically.
Below is the code I have now...
ForEachLoop forEachLoop = p.Executables.Add("STOCK:FOREACHLOOP") as
ForEachLoop;
// Create a VariableMappings and VariableMapping objects.
ForEachVariableMapping forEachVariableMapping =
forEachLoop.VariableMappings.Add();
// Create a mapping between the variable and its value.
forEachVariableMapping.VariableName = #"User::CurrentTableName";
forEachVariableMapping.ValueIndex = 0;
ForEachEnumeratorInfo forEachEnumeratorInfo =
runtimeApp.ForEachEnumeratorInfos["Foreach From Variable Enumerator"];
ForEachEnumeratorHost forEachEnumeratorHost =
forEachEnumeratorInfo.CreateNew();
You are almost there...I think you are forgetting to set the ForEachEnumerator property of the forEachLoop object.
ForEachLoop forEachLoop = p.Executables.Add("STOCK:FOREACHLOOP") as ForEachLoop;
ForEachEnumeratorInfo forEachEnumeratorInfo = runtimeApp.ForEachEnumeratorInfos["Foreach From Variable Enumerator"];
ForEachEnumeratorHost forEachEnumeratorHost = forEachEnumeratorInfo.CreateNew();
//forEachEnumeratorHost.CollectionEnumerator = false; // true or false; set accordingly.
// cast the inner object to ForEachFromVarEnumerator
ForEachFromVarEnumerator = forEachEnumeratorHost.InnerObject as ForEachFromVarEnumerator;
// Now that you have the ForEachFromVarEnumerator, set its properties.
// For variable name, do not forget the variable's name space and the variable name (separated by ::)
ForEachFromVarEnumerator.VariableName = "var_namespace" + "::" + "var_name";
// finally.....
forEachLoop.ForEachEnumerator = forEachEnumeratorHost; // DO NOT FORGET THIS. Here you are setting what the actual enumerator would be
You can do like this:
Script task
Make sure MyList variable is Writeable
ArrayList NewList = new ArrayList();
NewList.Add("Ost");
NewList.Add("Hest");
Dts.Variables["User::MyList"].Value = NewList;
Dts.TaskResult = (int)ScriptResults.Success;
The first step is
Add an assembly reference to Microsoft.SqlServer.ForEachFromVarEnumerator.dll and then one can get access to the Microsoft.SqlServer.Dts.Runtime.Enumerators.FromVar.ForEachFromVarEnumerator class.
And then the rest of the answer is exactly what #Sam has mentioned above.
I have a 3D array in Matlab of uint16(basically it is just an image 1080x1920x3). I want to store it in mysql. Here is what I'm doing:
MySQL:
create table imgtest(img longblob);
Matlab:
% image_data - is my image as described before
raw_im = reshape(image_data,1,[]);
conn = database('test','root','root','Vendor','MySQL','Server','localhost')
x = conn.Handle;
insertcommand = ['INSERT INTO imtest (img) values (?)'];
StatementObject = x.prepareStatement(insertcommand);
StatementObject.setObject(1,raw_im)
StatementObject.execute
The problem is that I'm writing about 600k uint16 values into this blob field. But when I take this field from the DB, I always getting about 1.2 million of uint8 elements(exactly two times more).
So, is there a way to read this byte field as a set of uint16, but not uint8?
Thank you.
I have been doing something similar for one of my projects
basically there was one difference but maybe it would clarify something to you.
I was loading image directly to DB from file with command:
INSERT INTO BaseImage(Image)
SELECT * FROM OPENROWSET(BULK N'C:\co.jpg', SINGLE_BLOB) as image
and getting it back to Matlab required typecasting (just like #sebastian mentioned)
SQL_query = 'select TOP 1 pk_BaseImage,Image from BaseImage order by pk_BaseImage desc';
[data] = SQL_query_exec(SQL_query);
pk_BaseImage = data.Data.pk_BaseImage;
out = typecast(data.Data.Image{1,1},'uint8');
BUT..
it was not enough, I had to do some trick to use 'out' as image
I was forced to write it to temporary file and read it again to Matlab (I know it's strange but it worked very well and I could for example calculate DWT, DFT and so on)
image_matrix = get_image_matrix( out );
get_image_matrix function looks like:
function [ out ] = get_image_matrix( input )
targetfilename = 'temp.jpg';
%wynik
fid = fopen(targetfilename,'w');
if fid
fwrite(fid,input,'uint8');
end
fclose(fid);
out = imread(targetfilename);
delete(targetfilename);
end
I hope it will help you :)
One important notice - I used gray-scale images (uint8 type)
You can most probably typecast the uint8's into uint16's to get back at your original image data:
uint16_result = typecast(uint8_result, 'uint16');
I'm not familiar with the database toolbox - so there might well be a way to tell Matlab to do this on its own.
OK, thank you both. I've summarized your answers and this what I've got:
Since blob field is nothing more than byte array, then we should cast our data in matlab before writing it to the DB. After reading it from DB, we should cast them back.
Minimum working example is:
MySQL
create table imgtest(img longblob);
Matlab
% image_data - is my image as described before
raw_im = typecast(reshape(image_data,1,[]),'uint8'); %! the main string
conn = database('test','root','root','Vendor','MySQL','Server','localhost')
x = conn.Handle;
insertcommand = ['INSERT INTO imtest (img) values (?)'];
StatementObject = x.prepareStatement(insertcommand);
StatementObject.setObject(1,raw_im)
StatementObject.execute
After we can read it back:
res = exec(conn,'Select * from imtest')
array_uint8 = fetch(res);
array_uint8 = array_uint8{1};
array_uint16 = typecast(array_uint8,'uint16').
Hope this will help someone.
I'm reading XML and attaching values to objects in two seperate movieclips. Like this
Map01:
Marker01.name = hello there
Marker01.short = hel
Marker01.value = 12
Map02:
Marker02.name = hello there
Marker02.short = hel
Marker02.value = 99
Now I'm clicking on Marker01 in Map01 and get its name and value. I want to compare its value to that of Marker01 in Map02, using the name, or better yet .short because the names are long and use special characters/spaces. How do I do this? I've pretty much tried everything that seemed logical!
EDIT: sample code for clarification
var marker01:mc_marker = new mc_marker();
marker01.name="hello there";
marker01.short="abc";
marker01.val="99";
marker01.x=10;
marker01.y=10;
this.mc_map01.addChild(marker01);
var marker02:mc_marker = new mc_marker();
marker02.name="hello there";
marker02.short="abc";
marker02.val="20";
marker02.x=10;
marker02.y=10;
this.mc_map02.addChild(marker02);
marker01.addEventListener(MouseEvent.MOUSE_UP, showMarkerInfo);
marker02.addEventListener(MouseEvent.MOUSE_UP, showMarkerInfo);
function showMarkerInfo(event:MouseEvent):void {
txt_ms.text=event.target.short;
txt_mv.text=event.target.val;
if (event.target.short==mc_map02.marker02.short){
txt_mvi.text="here should be the marker02 value";
}
}
You have a typo there. Map02 use Marker1 things.
If its a typo in Stackoverflow,
this.getChildByName( "Marker01" ) will return you the movieclip, buy its name. take care though, as "name" is what it searches for. You used "hello there" when you should put Marker01 as the name. I would suggest you put a property called "data" and put the xml info in it so it doesn't conflict.
In the end you have:
if( this.getChildByName( "Marker01" ).data.value == this.getChildByName( "Marker02" ).data.value ).
I assume this is because you generate Marker0X at runtime and you can't declare some variables and use them directly.
Browny points if you make "data" a instance of a custom class where you can compare two "data". If you need more help, add a comment ^_^