ElasticClient an error when checking the connection status - json

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!

Related

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

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.

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.

Username in WebTokenRequestResult is empty

in a Windows 10 UWP I try use WebAuthenticationCoreManager.RequestTokenAsync to get the result from a login with a Microsoft account.
I get a WebTokenRequestResult with Success. ResponseData[0] contains a WebAccount with an ID - but the UserName is empty.
The scope of the call is wl.basic - so I should get a lot of information...
I'm not sure how to retrieve extra information - and for the current test the Username would be OK.
I checked out the universal samples - and there I found a snippet which tries to do what I'm trying - an output of webTokenRequestResult.ResponseData[0].WebAccount.UserName.
By the way - the example output is also empty.
Is this a bug - or what do I (and the MS in the samples) have to do to get the users profile data (or at least the Username)?
According to the documentation (https://learn.microsoft.com/en-us/windows/uwp/security/web-account-manager), you have to make a specific REST API call to retrieve it:
var restApi = new Uri(#"https://apis.live.net/v5.0/me?access_token=" + result.ResponseData[0].Token);
using (var client = new HttpClient())
{
var infoResult = await client.GetAsync(restApi);
string content = await infoResult.Content.ReadAsStringAsync();
var jsonObject = JsonObject.Parse(content);
string id = jsonObject["id"].GetString();
string name = jsonObject["name"].GetString();
}
As to why the WebAccount property doesn't get set... shrugs
And FYI, the "id" returned here is entirely different from the WebAccount.Id property returned with the authentication request.

Insert query failing when using a parameter in the associated select statement in SQL Server CE

INSERT INTO voucher (voucher_no, account, party_name, rece_amt, particulars, voucher_date, voucher_type, cuid, cdt)
SELECT voucher_rec_no, #account, #party_name, #rece_amt, #particulars, #voucher_date, #voucher_type, #cuid, #cdt
FROM auto_number
WHERE (auto_no = 1)
Error:
A parameter is not allowed in this location. Ensure that the '#' sign is in a valid location or that parameters are valid at all in this SQL statement.
I've just stumbled upon this whilst trying to fix the same issue. I know it's late but, assuming that you're getting this error when attempting to execute the query via .net, ensure that you are setting the SqlCeParameter.DbType - if this is not specified, you get the exception you listed above.
Example (assume cmd is a SqlCeCommand - all the stuff is in the System.Data.SqlServerCe namespace):
SqlCeParameter param = new SqlCeParameter();
param.ParameterName = "#SomeParameterName";
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String; // this is the important bit to avoid the exception
param.Value = kvp.Value;
cmd.Parameters.Add(param);
Obviously, you'd want to set the DB type to match the type of your parameter.

sqlalchemy: Error with commit on session - 'SessionMaker' object has no attribute '_model_changes'

I'm new to SqlAlchemy. We were working primarily with Flask, but in a particular case I needed a manual database connection. So I launched a new db connection with something like this:
write_engine = create_engine("mysql://user:pass#localhost/db?charset=utf8")
write_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,bind=write_engine))
nlabel = write_session.query(Label).filter(Label.id==label.id).first() # Works
#Later in code
ms = Message("Some message")
write_session.add(ms) # Works fine
write_session.commit() # Errors out
Error looks like "AttributeError: 'SessionMaker' object has no attribute '_model_changes'"
What am I doing wrong?
From the documentation I think you might be missing the initialization of the Session object.
Try:
Session = scoped_session(sessionmaker(autocommit=False, autoflush=False,bind=write_engine))
write_session = Session()
It's a shot in the dark- I'm not intimately familiar with SQLAlchemy. Best of luck!
Your issue is that you are missing this line:
db_session._model_changes = {}