I have a map with a C# script in Script functoid to convert a date in dd/MM/yyyy format to yyyy-MM-dd format:
Here is the script I use in my functoid :
public string CheckDate(string inputDate)
{
if(String.IsNullOrEmpty(inputDate))
return "";
else
{
System.DateTime dt = System.Convert.ToDateTime(inputDate);
return dt.ToString("yyyy-MM-dd");
}
}
For an unknow reason this script works perfectly when I do a Test Map in VS, it also works on my DEV environment but when I deploy it on UAT I got this error message:
General Exception : Error encountered while executing the transform
XXX. Error:Transformation failed..
I already tried to use TryParse() or TryParseExact() but the mapping behavior is still the same. Work on DEV and Test Mapping but not on UAT.
EDIT
I catched the InnerException from Error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.Convert.ToDateTime(String value)
at System.Xml.Xsl.CompiledQuery.Script1.ConvertCompletedDate(String param)
So the issue is the input value but I only desn't work on UAT environment. This error is not thrown on DEV. I checked the .NET framework used and they are the same on both environment.
Can someone tells me how I can transform 18/11/2021 to a valid DateTime format ?
I finally figured out that my TryParseExact() wasn't good.
If you have these kind of error and the issue concern a DateTime, the answer is the #Shar1er80 's reply here
Related
I am writing a compiler targeting the common intermediate language and want to use .data-declarations for globals. I mean section II.16.3.1 of the Spec.
How can I use what is described as "Address of label"? The following does assemble using .NET-Core's ilasm:
.assembly extern mscorlib
{
.ver 4:0:0:0
}
.assembly 'string'
{
}
.module 'string'
.data hello_world_data = { int8(72), int8(101), int8(108), int8(108), int8(111), int8(32), int8(87), int8(111), int8(114), int8(108), int8(100), int8(33), int8(0) }
.field static int8 hello_world at hello_world_data
.data addr_of_data = &(hello_world_data)
.field static int8* hello_world_ptr at addr_of_data
.method public static default int32 main () cil managed {
.entrypoint
ldc.i4.0
ret
}
But when I try to execute the code above, I get the following error message (using .NET-Core on Linux):
Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/home/lou/uni/proj/stuff/tests/test-global-arrays/string.exe'. An attempt was made to load a program with an incorrect format.
File name: '/home/lou/uni/proj/stuff/tests/test-global-arrays/string.exe'
[1] 12019 abort (core dumped) dotnet string.exe
Any ideas/help?
If this is important for you, I would suggest filing an issue in the https://github.com/dotnet/runtime repo.
I assume the reason this doesn't work outside Windows is because these directives generate data with relocations (places within the executable that need to be fixed up with a real address once the executable is loaded into memory). Since the format of the executables in .NET is based on the Windows PE format, the relocation is processed by Windows when it loads the executable.
Outside Windows, CoreCLR ships with a small "Windows loader emulator" that loads the .NET executables the way Windows would load them. But it probably misses the handling for these relocations. The IL format doesn't generate relocations otherwise.
But these relocations are going to be problematic in many places (I fully expect e.g. tools like the IL Linker to miss them and damage them, I assume Mono doesn't have handling for the these either, they are going to be problematic for AOT compilation, etc.).
I am coming to you because I have a problem with prestashop, when I try to generate an invoice after purchase, the site sends me back to an error 500 and I cannot recover my invoice, what to do?
Error returned to me by the site in production mode:
Oops! An Error Occurred
The server returned a "500 Internal Server Error".
Something is broken. Please let us know what you were doing when Ibis error occurred. We will fur it as soon as possible. Sorry for any inconvenience caused.
Error returned to me by the site in developement mode:
ClassNotFoundException
Attempted to load class "DpTools" from the global namespace. Did you forget a "use" statement?
in override/classes/order/OrderInvolce.php (line 52)
$products = parent::getProducts($products, $selected_products, $selected_pty);
if (is_array($products)))
{
foreach ($products as $index => $product)
{
if ((int)$product['id_product'] == DpTools::getSpecialProduct())//<< error Line
unset($products[$index])
}
}
return $products;
}
This error means that your Prestashop OrderInvoice.php file had been overriden by a module and it's not the original one.
Try inspecting
override/classes/order/OrderInvoice.php
in your FTP - You should be able to find the module name that is causing the override in a comment.
Then try to disable or uninstall that module and see if the issue is still there.
Otherwise you can try to rename that override/classes/order/OrderInvoice.php and empty the cache so the original one will be used , this will probably interfere with that module functionalities , though.
call pybot --timestampoutputs --log mylog.html --report NONE tests.html
[ ERROR ] Parsing 'tests.html' failed: Data source does not exist.
I want to create report with time stamp but throws error. Any example as how to generate reports with unique name with time-date.
The error you report, "Data source does not exist", is not because of your use of the --timestampoutputs option. It's because robot can't find "tests.html".
--timestampoutputs works fine when you give it a valid test suite. For example, when I ran the code in your question I ended up with a log file named mylog-20150220-053904.html.
According to the docs (http://luasqlite.luaforge.net/lsqlite3.html#sqlite3.open)
In case of an error, the function returns nil, an error code and an
error message.
But I always get the same results no matter if I provide a valid or invalid SQLite file. In fact, if I provide an inexistent file or an invalid path I still get the same results. For example:
db, code, msg = sqlite3.open("foo"))
print(db) -- sqlite database (0x7f9ab1628598)
print(code) -- nil
print(msg) -- nil
How can I catch these errors?
sqlite3.open creates a file if it does not exist. So, providing an inexistent file is not an error.
Providing an invalid path should be an error. Calling sqlite3.open("/foo/bar") will probably give you an error.
Another kind of error is a permission error. Calling sqlite3.open("/foo") if you're running some kind of Unix should give you a permission denied error.
I have developed a Symfony2 project (v2.2.2) and it was working all fine locally.
When I deploy it on my server I meet 2 issues:
the folder /bin does not transfer through Filezilla (impossible to start transfer)
i encounter a parse error when trying to access web/app.php/ in debug mode (see below)
First I do not understand why it would work in local but not on production.
I also guessed these errors where linked but I do not know what is /bin used for (contains only 2 files doctrine and doctrine.php) and if I remove it locally it keeps working ...
Parse error is the following :
"FatalErrorException: Parse: syntax error, unexpected '[' in /home/colocall/twinkler/src/Tk/ExpenseBundle/Services/Expenses.php line 21"
Expenses.php line 15->25:
public function getAllExpenses($member, $group)
{
$all_expenses_col = $group->getExpenses();
$all_expenses = array();
foreach($all_expenses_col as $expense){
$all_expenses[] = [$expense, $this->forYou($member, $expense)];
}
return $all_expenses;
}
Maybe linked to : The parse error also happen when i try to update my database through ssh connection.
If someone would know the reason why I can't make it working it would save my day that i have already lost ...
Thank you in advance,
Jules
Your error is produced by using the short array syntax [] in your code.
It is not available in PHP 5.3.10 aka on your production server. The short syntax was introduced in PHP 5.4 which explains why your code is working in your dev-environment.
change ...
$all_expenses[] = [$expense, $this->forYou($member, $expense)];
...to
$all_expenses[] = array($expense, $this->forYou($member, $expense));
... or update your server's php version and it will work :)