BizTalk SMTP The part 'PartAttachment' of message 'msg_Email' contained a null value at the end of the construct block - smtp

Quick summary of issue - when I set the RawString to text, the email with attachment is sent and properly named. When I set the attachment to a RawString message, I get the error "The part 'PartAttachment' of message 'msg_Email' contained a null value at the end of the construct block."
I have created my own RawString class which I have used before. The orchestration receives a CSV file via a pass-thru pipline. Following some documentation I found, I receive a XmlDocument, and in the next shape, I construct the RawString as follows:
msg_Raw_String.MessagePart_1 = msg_Ledger6002_File_XmlDoc;
However if I set the to dummy text in RawString, the email with attachment is sent (the attachment is just a text file with the value below:
msg_Email.PartAttachment = new XXXLedger6002.Component.RawString("Test Text");
Full code in message assignment:
msg_Email.BodyPart = new XXXLedger6002.Component.RawString("See attached email. Method 2 Dynamic");
// Force some value to make sure it is not null
//msg_Email.PartAttachment = new Ledger6002.Component.RawString("Test Text");
// Tried both of these, same error:
//msg_Email.PartAttachment = msg_Ledger6002_File_XmlDoc;
msg_Email.PartAttachment = msg_Raw_String.MessagePart_1;
// syntax doesn't allow this:
// msg_Email.PartAttachment = msg_Raw_String;
// Set the filename as it should display on the attachment in the email
// (drop the path, just the filename/extension)
attachmentName = System.IO.Path.GetFileName(
msg_Ledger6002_File_XmlDoc(FILE.ReceivedFileName));
msg_Email.PartAttachment(MIME.FileName) = attachmentName;
//msg_Email.BodyPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";//
//msg_Email.AttachmentPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
msg_Email(SMTP.Subject) = "Ledger6002 File";
msg_Email(SMTP.SMTPTo) = msg_Config_Email.smtpToEmail;
msg_Email(SMTP.From) = msg_Config_Email.smtpFromEmail;
msg_Email(SMTP.SMTPAuthenticate) = 0; // do not authenticate to SMTP server
msg_Email(SMTP.SMTPHost) = msg_Config_Email.smptHostName;
// msg_Email(SMTP.EmailBodyText) = "UTF-8";
msg_Email(SMTP.EmailBodyTextCharset) = "UTF-8";
msg_Email(SMTP.MessagePartsAttachments) = 2;
// No email generated with comment out line, trying same without mailto:
SMTP_Dyn_Email(Microsoft.XLANGs.BaseTypes.Address) = "mailto:" + msg_Config_Email.smtpToEmail;
SMTP_Dyn_Email(Microsoft.XLANGs.BaseTypes.TransportType) = "SMTP";
Error:
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Ledger6002.Logic.Ledger6002_Process_File(9eb6993c-87d0-7bf0-b0bf-e1f684000af2)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: ecaa7ed2-04c1-46b9-b845-cf3211b83387
Shape name: Send_Dyn_Email
ShapeId: 4ada59c3-367e-40b4-babc-d0d9999feb77
Exception thrown from: segment 1, progress 60
Inner exception: The part 'PartAttachment' of message 'msg_Email' contained a null value at the end of the construct block.
Exception type: NullPartException
Source: Microsoft.XLANGs.Engine
Target Site: System.IO.Stream Persist(System.String ByRef, Boolean)
The following is a stack trace that identifies the location where the exception occured
at Microsoft.XLANGs.Core.CustomFormattedPart.Persist(String& encoding, Boolean wantEncoding)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.StagePartData(Part part)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.PrepareMessage(XLANGMessage msg, IList promoteProps, IList toPromote)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.WriteMessageState(IBTPEPInfoLookup pepLookup, Guid portId, XLANGMessage msg, Segment seg, String opname, String url, IList promoteProps, Boolean track, IList toPromote)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXLogicalPortBinding.SendMessage(XLANGMessage msg, XlangStore store, Segment seg, OperationInfo op, IList additionalProps, IList toPromote, Boolean ignoreRoutingFailure)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.SendMessage(Int32 iOperation, XLANGMessage msg, Correlation[] initCorrelations, Correlation[] followCorrelations, Context cxt, Segment seg, ActivityFlags flags)
at Ledger6002.Logic.Ledger6002_Process_File.segment1(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)

The following is a get-around that seems to work.
msg_Email.PartAttachment = new SBA.Ledger6002.Component.RawString(
msg_Raw_String.MessagePart_1.ToString());
If anybody can explain why I just can't set it to msg_Raw_String.MessagePart_1, I would love to know.

Related

How to pass a local exception object to a class?

I want to pass an error local object in a class method which will display a detail error to the user.
This is the current code:
CATCH cx_root INTO lcx_general_error.
DATA(lv_longtext) = lcx_general_error->get_longtext( ).
lcx_general_error->get_source_position(
IMPORTING
program_name = lv_program_name
include_name = lv_include_name
source_line = lv_program_line
).
DATA(lv_program_include) = |{ lv_program_name }/ { lv_include_name }|.
DATA(lv_length_message) = strlen( lv_longtext ).
DATA(lv_error_message1) = lv_longtext(50).
IF lv_length_message > 50.
DATA(lv_remaining) = lv_length_message - 50.
DATA(lv_error_message2) = lv_longtext+50(lv_remaining).
ENDIF.
MESSAGE e001 WITH lv_error_message1 lv_error_message2
lv_program_include
lv_program_line.
Instead, I want to create a class method and pass any local object that refers to any error and display the error detail message:
CATCH cx_root INTO lcx_general_error.
lo_fi_uploads->display_error( lcx_general_error ).
How to create and use this parameter in the local class?
Exceptions are regular classes with regular object instances, so declare them like any other object parameter:
METHODS display_error
IMPORTING
exception TYPE REF TO cx_root.
In the method’s implementation you can then paste the code you already have:
METHOD display_error.
DATA(lv_longtext) = exception->get_longtext( ).
exception->get_source_position(
IMPORTING
program_name = DATA(lv_program_name)
include_name = DATA(lv_include_name)
source_line = DATA(lv_program_line)
).
DATA(lv_program_include) = |{ lv_program_name }/ { lv_include_name }|.
DATA(lv_length_message) = strlen( lv_longtext ).
DATA(lv_error_message1) = lv_longtext(50).
IF lv_length_message > 50.
DATA(lv_remaining) = lv_length_message - 50.
DATA(lv_error_message2) = lv_longtext+50(lv_remaining).
ENDIF.
MESSAGE e001 WITH lv_error_message1 lv_error_message2
lv_program_include
lv_program_line.
ENDMETHOD.
People often fear that working with exceptions might accidentally trigger them. That won’t happen. As long as you do not invoke the RAISE statement, exceptions are really quite ordinary objects. You can even instantiate them with NEW without triggering them.

DataReader->ReadString throws exception

I have code below. Creating array of BYTEs, filling it with some sytes, and then trying to read it. When reading, i got an error:
int imageSize = 1024;
BYTE* input = new BYTE[imageSize];
// input is filling by some bytes..
DataWriter ^writer = ref new DataWriter();
writer->WriteBytes(ArrayReference<BYTE>(input, imageSize));
IBuffer ^buffer = writer->DetachBuffer();
DataReader ^ reader = DataReader::FromBuffer(buffer);
auto res = reader->ReadString(buffer->Length); // THIS STRING THROW Platform::COMException ^
Strings cannot contain random data - they must contain well-formed Unicode code-points. I assume the error (which you don't include) says this:
HRESULT:0x80070459 No mapping for the Unicode character exists in the target multi-byte code page.
From the name of your variable (imageSize) it sounds like you're trying to load bitmap data, which is not a valid String.

Error trying to Upload image using srrs using rs.exe -"The required field Property is missing from the input structure"

Scenario : Upload image using srrs using rs.exe (using code not GUI)
Environment : Sql server 2012, rs.exe , vb.script
'Utility to Publish the Png file ( snippet)
'Sample inputs PublishImageFile("myimagefilename.png", "image/png")
Public Sub PublishImageFile(ByVal imageName As String,ByVal resourceMIME As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + "\" + imageName)
definition = New [Byte](stream.Length - 1) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()
Catch e As IOException
Console.WriteLine(e.Message)
End Try
imageName = imageName.tostring.replace(".png", "")
Console.WriteLine("Attempting to Deploy Resource Name {0}", imageName.tostring)
Dim item As CatalogItem
Dim mimeProperty As New Microsoft.SqlServer.ReportingServices2010.Property
mimeProperty.Name = "MimeType"
mimeProperty.Value = resourceMIME
Dim properties(1) As Microsoft.SqlServer.ReportingServices2010.Property
properties(0) = mimeProperty
Try
item = rs.CreateCatalogItem("Resource", imageName, ReportFolder, True,
definition, properties, warnings) 'Error line
'More code below removed for brevity
Error I receive in the last line above is
The required field Property is missing from the input structure. ---> Microsoft.ReportingServices.Diagnostics.Utilities.MissingElementException: The required field Property is missing from the input structure.
What are the required parameters required in the properties object to fix the issue.
I did not find the same in CreateCatalogitem method in MSDN
https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.createcatalogitem(v=sql.120).aspx
Nor in the Catalog item description in MSDN
https://msdn.microsoft.com/en-us/library/reportservice2010.catalogitem.aspx
From the error message and investigation it appears ( my assumption) like a required field named 'Property' could missing from the properties array. But what would be its value?
Please share your suggestions & solutions or may be even an code alternative to rs.exe to automate deploy images to ssrs using script.
I found the answer. I just added an additional property named property and name as filename just before the CreateCatalogItem method and it worked!
Dim propertyItem As New Microsoft.SqlServer.ReportingServices2010.Property
propertyItem.Name = "Property"
propertyItem.Value = imageName
properties(1) = propertyItem

Elm Json request not working?

In Elm, you can use the Json.decode and Http package to request json data. My attempt was to work out a periodic lookup for emails ( from this url ). The timer operation does work (i tried it with with a simple counter).
I have used this example and this SO question as reference.
Now the types:
type alias Email = { title: String, ... }
type Action =
NoAction
| TickCounter -- TODO rem
| AddEmails (List Email)
Then the main + state + actions ...
main: Signal Html
main = Signal.map (view actions.address) state
state: Signal Model
state = Signal.foldp update makeEmptyModel input
-- handle inputs (merging signals)
input : Signal Action
input =
Signal.mergeMany
[ actions.signal
-- , other actions
, Signal.map checkForNewMails (Time.every (Time.minute / 6.0) ) -- TODO precise timer (quick test)
]
actions: Signal.Mailbox Action
actions = Signal.mailbox NoAction
update: Action -> Model -> Model
update action model =
case action of
NoAction -> model
TickCounter -> { model | count = model.count + 1 }
AddEmails newMails -> { model | emails = newMails }
checkForNewMails: Time -> Action
checkForNewMails t =
let mails = startGettingEmailData
in TickCounter -- TODO replace with AddEmails using mails
The TickCounter is an Action, which i have used to test my timing operation. But the problem is startGettingEmailData. It uses the next snippet, but it doesn't fire any JSON request (i have checked it through the console). Once that has been resolved, i can convert mails to an action so that i can add the emails in the model.
-- url to json
jsonUrl = "https://dl.dropboxusercontent.com/u/14070433/temp.json"
-- get emails
startGettingEmailData: Task Http.Error (List Email)
startGettingEmailData = Http.get emailJsonDecoder jsonUrl
emailJsonDecoder: Json.Decoder (List Email)
emailJsonDecoder =
let makeEmail = Json.object4
(\ti fr da bo -> makeNewEmail -1 ti fr da bo )
("title" := Json.string)
("from" := Json.string)
("date" := Json.string)
("body" := Json.string)
in
"emails" := Json.list makeEmail
Is there a problem with my code ? If not, then is there a way to check the Http.Error content ? (Maybe the problem lies not in my code, but in the network, but i can access the dropbox file by browser...)
Your code for checkForNewMails doesn't actually do anything with mails, so it never gets invoked. The let statement doesn't make any calls, it only lets you define one-off functions within the body of a larger function. Since the in portion merely returns TickCounter, then it means this function only ever returns TickCounter and does nothing else.
Furthermore, startGettingEmailData is returning a Task, which means it only gets invoked when in a port. You can't use it in a function that only returns an Action, because it would never get run.
You'll instead want to write a port that triggers on a timer, then creates a Task which polls your url, then maps the response of that GET request to an Action, calling the actions mailbox. You can use Task.onError to write a simple error handler, which could forward an error message to your view by creating an Error String constructor on your Action type.
Here's an example:
getEmailData _ =
let
request =
Http.get emailJsonDecoder jsonUrl
|> Task.map AddEmails
in
request
`Task.onError` (\err -> Task.succeed (Error (toString err)))
`Task.andThen` (\action -> Signal.send actions.address action)
port getEmails : Signal (Task a ())
port getEmails =
Signal.map getEmailData (Time.every (Time.minute / 6.0) )
The above code will cause the URL to be retrieved, parsed, then, on success, it will trigger you actions mailbox and cause an update of the view. If there is an error, it will send the new action of Error with a message, which you should handle in the view. (You'll have to add Error String to the Action union type and handle it in the model, update, and view functions).

ElasticClient an error when checking the connection status

I'm trying to check the connection status, but there is an exception when checking.
var node = new Uri("http://myhost:9200");
var settings = new ConnectionSettings(node);
ElasticClient client = new ElasticClient(settings);
IStatusResponse status = client.Status();
After calling client.Status() throws an exception Newtonsoft.Json.JsonReaderException
JSON integer 12500348306 is too large or small for an Int32. Path 'indices.companyindx.index.primary_size_in_bytes', line 1, position 37862.
If i do not check the status of call, then everything works fine.
I'm using C # and Nest 1.0.0-beta1
What could be the reason?
This is actually a bug in NEST, more info here. Should be fixed in the next release if that PR is merged. Good find!