C# How to find two different strings at one search in RichTextbox - search

I have a lot of Android log in RichTextbox loaded from file.
Lets say i search for "Fatal" word by default search method and i got this:
10-11 19:37:44.647 19525 19789 E AndroidRuntime: FATAL EXCEPTION: IntentService[ContactSaveService]
But, as I know there is possibility that there will be more than 1 exception in dumpstate.
So i thought, it would be nice to compare file name with line of Fatal in this log.
File name: dumpstate_app_201210111708___error
Error log: 10-11 19:37:44.647
It doesnt match.
So i would like to do something like this:
if(rtb.Lines[i].contains(date_of_exception))
{
rtb.Select(startPos, text.Length);
rtb.ScrollToCaret();
rtb.Focus();
}
Of course it doesnt work. I have no idea how to solve it.
I thought about getting number of line with found text and search if this line contains date_of_exception
What I am sure. Time of fatal exception must be the same with time in file name. And that's why i need to check if line in richtextbox contains "fatal" word and time of exception from file name.
I hope it is clear, if not, i will try to describe it better.
Thanks in advance

Related

Blue Prism expression to get most recent file from folder

I am trying to write an expression on putting an attachment in the Outlook VBO and keep getting error that it cant find the file.
The file name is Investment Value_2022-12-13h12m37s45.xlsx bit everything after value will be different.
I have tried writing it as a wild card.
"C:\Users\AAPWP\Downloads\Investment*"
I tried filtering it into its own collection and getting it that way.
"File.File"
Trying to get the file path from a filtered collection.
"Attachment.Folder.Name"
Anybody having the same issue and any help would be appreciated.
Use 'Utility - File Mangement: Get Files' action to get all excel files
Loop through each file name and use 'Decision' action to check for file name pattern
Use formula - InStr([Files.Name], "Investment Value_") > 0
If True, then thats the file you need

open() throwing mypy issues which reading an image file

I have the following line of code which reads an image (which is fed into a POST request):
files = {"image": (image_path, open(image_path, "rb"))}
While trying to run this through mypy, it keeps throwing the following error:
Argument 1 to "open" has incompatible type "Optional[str]"; expected "Union[Union[str, bytes, PathLike[str], PathLike[bytes]], int]"
I've tried searching this, but I've not found a solution for similar problems.
Is there a different way to read filepaths in order to avoid these issues?
Not the correct answer but if you want to temporarily make it go away to move ahead:
# type: ignore
at the end of the erroring line should work.

Opening .hoc files in neuron simulator + "not a mechanism" problem

I am trying to run a NEURON simulation via python. I got all the libraries in order and am able to run some simple simulations, but am experiencing some troubles with a more complicated code. If you have any idea how to help I will appreciate it very much
Problem number 1:
Neuron doesn't open part of a .hoc file even though it is compiled. I get the error:
NEURON: Can't open import3d/import3d_sec.hoc
in import3d.hoc near line 1
{xopen("import3d/import3d_sec.hoc")}
^
xopen("import3d/i...")
xopen("import3d.hoc")
execute1("{xopen("im...")
load_file("C:/Users/U...")
Problem number 2:
The simulator doesn't recognize a mechanism I am trying to use. here I am a bit lost and don't know to describe further, but this is the error message:
NEURON: Im is not a MECHANISM
in L5PCbiophys5b.hoc near line 26
insert Im
^
xopen("L5PCbiophy...")
execute1("{xopen("L5...")
load_file("C:/Users/U...")
Problem number 3:
Not recognizing as a template:
NEURON: Import3d_Neurolucida3 is not a template
in L5PCtemplate_2.hoc near line 26
nl = new Import3d_Neurolucida3()
^
xopen("L5PCtempla...")
execute1("{xopen("L5...")
load_file("C:/Users/U...")
You can try to use an absolute path
The name for insert should match with the SUFFIX statement in the file; also make sure that file was compiled in and that the dll is loaded (should be a message when you start nrniv)
Perhaps a result of the file xopen problem? If it is a template-containing file you should use load_file() instead of xopen()

How Do I resolve "Illuminate\Queue\InvalidPayloadException: Unable to JSON encode payload. Error code: 5"

Trying out the queue system for a better user upload experience with Laravel-Excel.
.env was been changed from 'sync' to 'database' and migrations run. All the necessary use statements are in place yet the error above persists.
The exact error happens here:
Illuminate\Queue\Queue.php:97
$payload = json_encode($this->createPayloadArray($job, $queue, $data));
if (JSON_ERROR_NONE !== json_last_error()) {
throw new InvalidPayloadException(
If I drop ShouldQueue, the file imports perfectly in-session (large file so long wait period for user.)
I've read many stackoverflow, github etc comments on this but I don't have the technical skills to deep-dive to fix my particular situation (most of them speak of UTF-8 but I don't if that's an issue here; I changed the excel save format to UTF-8 but it didn't fix it.)
Ps. Whilst running the migration, I got the error:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `jobs` add index `jobs_queue_index`(`queue`))
I bypassed by dropping the 'add index'; so my jobs table is not indexed on queue but I don't feel this is the cause.
One thing you can do when looking into json_encode() errors is use the json_last_error_msg() function, which will give you a bit more of a readable error message.
In your case you're getting a '5' back, which is the JSON_ERROR_UTF8 error code. The error message back for this is a slightly more informative one:
'Malformed UTF-8 characters, possibly incorrectly encoded'
So we know it's encountering non-UTF-8 characters, even though you're saving the file specifically with UTF-8 encoding. At first glance you might think you need to convert the encoding yourself in code (like this answer), but in this case, I don't think that'll help. For Laravel-Excel, this seems to be a limitation of trying to queue-read .xls files - from the Laravel-Excel docs:
You currently cannot queue xls imports. PhpSpreadsheet's Xls reader contains some non-utf8 characters, which makes it impossible to queue.
In this case you might be stuck with a slow, non-queueable option, or need to convert your spreadsheet into a queueable format e.g. .csv.
The key length error on running the migration is unrelated. It has been around for a while and is a side-effect of using an older version of MySQL/MariaDB. Check out this answer and the Laravel documentation around index lengths - you need to add this to your AppServiceProvider::boot() method:
Schema::defaultStringLength(191);

NLog:: adding source code line number to the log

I need source code line number to the log entry through NLog.
Please let me know alternate ways to do it.
<<Log entry>> Line 23
<<Log entry>> Line 391
P.S. - 23, 391 are the source code line numbers.
Thanks
You may use ${callsite:fileName=true} layout renderer - indicates whether to render the source file name and line number. Documentation.
Not sure but you should try this. Hope it will help :D
http://iosdevelopertips.com/cocoa/filename-and-line-number-with-nslog-part-ii.html
and I also found this
NSLog(#"current line: %d",__LINE__);
from this
How can I log the current line via NSLog in Cocoa / Objective C?
EDIT sry I dont know that u want C#
should try look at this
Do __LINE__ __FILE__ equivalents exist in C#?

Resources