The following are the ESC codes for Micrsoft.PointOfService printers:
string escAlignCenter = String.Format("{0}|cA", ((char)27));
string escAlignRight = String.Format("{0}|rA", ((char)27));
string escBoldOn = String.Format("{0}|bC", ((char)27));
string escNewLine = String.Format("{0}|1lF", ((char)27));
string escPaperCut = String.Format("{0}{1}|P", ((char)27), AppSettings.POSPrinterLinesToCut);
string escReset = String.Format("{0}|N", ((char)27));
string escUnderlineOn = String.Format("{0}|uC", ((char)27));
This code
simulatedReceipt.AppendLine(string.Format("{0}{1}Header will appear Here{2}", escBoldOn, escAlignCenter, escReset));
when sent to the simulator printer with
textToPrint = simulatedReceipt.ToString();
posPrinter.PrintNormal(PrinterStation.Receipt, textToPrint);
results in:
System.FormatException occurred
HResult=-2146233033
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at Microsoft.PointOfService.DeviceSimulators.PosPrinterSimulatorWindow.ProcessEscapes(String str)
at Microsoft.PointOfService.DeviceSimulators.PosPrinterSimulatorWindow.DisplayText(String str)
at Microsoft.PointOfService.DeviceSimulators.PosPrinterSimulator.PrintNormalImpl(PrinterStation station, PrinterState printerState, String data)
at Microsoft.PointOfService.BaseServiceObjects.PosPrinterBase.OutputRequestHandler(OutputRequest Request)
at Microsoft.PointOfService.Internal.PosCommonInternal.ProcessOutputRequest(OutputRequest request, Boolean asyncOperation)
at MyCourts.PrintReceiptManager.printToPOSPrinter() in e:\MyCourts\MyCourts\Managers\PrintReceiptManager.cs:line 558
InnerException:
Unfortunately I don't have an appropriate receipt printer to test it on but I suspect the error only occurs with the built-in thermal printer simulator.
Can anyone confirm my suspicions please.
After examining the SDK examples it is apparent that control codes are removed prior to sending to the simulator so it appears that the simulator will not simulate BOLD etc.
Related
I am using OData to query data from my SQL Db, I am trying to filter data using a Date value. See query below:
http://localhost:4409/OrderMaintenance?$filter=DocType%20eq%205%20and%20DocState%20in%20(0,1,2,3,4,5,6,7)%20and%20InvDate%20eq%202022/02/21
Only the date is the problem in this query because when I remove the date filter the query works fine.
The InvDate is of type:
orderDateFilter: Date = new Date();
I then formatted the date to:
this.orderDateFilter.toLocaleDateString()
which returns date as :
2022/02/21
But I am getting the following error
"The query specified in the URI is not valid. An identifier was expected at position 62."
Stacktrace:
at Microsoft.OData.UriParser.ExpressionToken.GetIdentifier()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseSegment(QueryToken parent)\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParsePrimary()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseInHas()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseUnary()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseMultiplicative()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseAdditive()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComparison()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalAnd()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalOr()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpression()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpressionText(String expressionText)\r\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)\r\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilter()\r\n at Microsoft.AspNet.OData.Query.FilterQueryOption.get_FilterClause()\r\n at Microsoft.AspNet.OData.Query.Validators.FilterQueryValidator.Validate(FilterQueryOption filterQueryOption, ODataValidationSettings settings)\r\n at Microsoft.AspNet.OData.Query.FilterQueryOption.Validate(ODataValidationSettings validationSettings)\r\n at Microsoft.AspNet.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\r\n at Microsoft.AspNet.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings)\r\n at Microsoft.AspNet.OData.EnableQueryAttribute.ValidateQuery(HttpRequestMessage request, ODataQueryOptions queryOptions)\r\n at Microsoft.AspNet.OData.EnableQueryAttribute.<>c__DisplayClass0_0.<OnActionExecuted>b__1(ODataQueryContext queryContext)\r\n at Microsoft.AspNet.OData.EnableQueryAttribute.ExecuteQuery(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, Func`2 modelFunction, IWebApiRequestMessage request, Func`2 createQueryOptionFunction)\r\n at Microsoft.AspNet.OData.EnableQueryAttribute.OnActionExecuted(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, IWebApiRequestMessage request, Func`2 modelFunction, Func`2 createQueryOptionFunction, Action`1 createResponseAction, Action`3 createErrorAction)
Try to format the odata date filter with dashes instead of backslashes:
2022-02-21 instead fo 2022/02/21.
You might also need to add the time portion. Here's an example with time at midnight 2022-02-21T00:00:00Z.
I used :
this.orderDateFilter.toISOString()
to convert my date to:
2022-02-22T09:17:24.822Z
But then I had issues querying, because I wanted to only check the Date excluding the Time. So instead I used:
this.datepipe.transform(this.orderDateFilter.toLocaleDateString(),'yyyy-MM-dd')
Which worked perfectly!
If you are using a .NET client (e.g. blazor) to call the API, convert the date to UTC date.ToUniversalTime() then format it as ISO 8601 by using date.ToString("o").
This will include the timezone with the Z (Zulu).
Or convert to sortablesafe string then append the Zulu
date.ToString("s") + Z
I am learning opencsv now,the method parseLine(String nextLine, boolean multi) in CSVParser is a little complex. What is the mearning of the field 'inField' in the class CSVParser? What does 'inQuotes' and 'fromQuotedField' denote in method parseLine(String nextLine, boolean multi); Thanks!
about line 112 in CSVParser : private boolean inField = false ;
about 348 line in parseLine(String nextLine, boolean multi):
boolean inQuotes = false;
boolean fromQuotedField = false;
The inQuotes tells the parser that the data it is reading is inside a quoted string - so if a delemeter character is met then it is part of the string instead of a signal to start a new field.
inField has basically the same functionality but it is a global variable (and it is not dependent on quotations). The reason openCSV needs to know this is that the CSVReader feeds the one line at a time - so if there is a line feed inside one of the fields then it will take multiple calls to the CSVParser to build one complete record. Hence the parseLineMulti.
The fromQuoteFields is a new addition for feature request #60. This is used with the null field indicator to detect if you have a set of empty quotes should the field be an empty string or null.
I allow user input from TinyMCE on client and store it as a JSON string, then pass it to server ASP.NET C#.
The JSON String looks like this: { "mcfn2" : ";lt;p;gt;Trước đ& oacute;, việc tung ra t& ecirc;n miền lần đầu ti& ecirc;n được sự đồng & yacute; của ICANN - tổ chức quản l& yacute; t& ecirc;n miền quốc tế" } (JSON string contains Vietnamese accent)
But when process on server, I received error "Unterminated string. Expected delimiter: ". Line 1, position ...." (It looks like the error happened because of đ& oacute;). (In this page, I seperate & with character after it by a space, because it will automacally converted to a Vietnamese if there are no space)
There are no error if user input is English text (no Vietnamese accent).
Please guide me how to fix this error.
I know at this time this will probably not be useful for you, but maybe it can help another person.
You should convert your string to UTF8 to deal with accents (Vietnamese and many other languages) before serializing it to JSON. For that you can use this function:
private string ConvertToUtf8(string textOriginal)
{
if (!string.IsNullOrEmpty(textOriginal))
{
byte[] bytes = Encoding.Default.GetBytes(textOriginal);
return Encoding.UTF8.GetString(bytes);
}
return string.Empty;
}
Have an application which publishes XML data across webservice using SOAP.
The data is pulled directly from an Oracle database and parsed into XML but for some reason the data being pulled out of the DB is throwing the following invalid XML exception.
Have done a bit of research and it looks like it may be a NULL character somewhere in the data which XML parser doesn't like.
Just wondering if anyone had seen this before and if so were they able to fix it at application or database layer?
Thanks!
Here's stack trace...
Exception System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character. Line 1, position 79763.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar)
at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, BufferBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.ParseText()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReaderImpl.Read()
at System.Xml.XmlValidatingReader.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at Microsoft.Web.Services2.Security.MessageSignature.PreProcessElementInput(XmlElement elem)
at Microsoft.Web.Services2.Security.SignatureReference.CalculateHashValue(XmlDocument document, CanonicalXmlNodeList refList)
at Microsoft.Web.Services2.Security.MessageSignature.BuildDigestedReferences()
at Microsoft.Web.Services2.Security.MessageSignature.ComputeKeyedHashSignature(SymmetricKeyAlgorithm key)
at Microsoft.Web.Services2.Security.MessageSignature.ComputeSignature()
at Microsoft.Web.Services2.Security.Security.SerializeXml(SoapEnvelope document)
at Microsoft.Web.Services2.Security.SecurityOutputFilter.ProcessHeader(Security security, SoapEnvelope envelope)
at Microsoft.Web.Services2.Security.SecurityOutputFilter.ProcessMessage(SoapEnvelope envelope)
at Microsoft.Web.Services2.Pipeline.ProcessOutputMessage(SoapEnvelope envelope)
at Microsoft.Web.Services2.OutputStream.Close()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
UPDATE: Here is a selection of data being published.Just plain text basically, this is how it exists in database columns, have included as comma separated.
614494, 2003, 33, 327, 15961, 59652, 2, 2, 3, 2, 1, 10-Dec-08, MY2003 AERO SEDAN, Manual 2.0
What kind of data are you pulling from Oracle? A blog? Image blob?
The reason I ask is Images have headers, which means there will be a null char after the header. Not sure how to escape the null char, however, to make it valid for serialization, but you can possibly do something like base64 encode the image, which will mnean reversing the base64 conversion on the other end.
Outside of that, you should post the exact data you are pulling from Oracle, as that might help with a more specific answer.
im creating temporary files to be stored in the Temp folder found by:
string path = System.IO.Path.GetTempPath()
method returns C:\windows\Temp\
i append my filename:
string filename = myfile.txt
System.IO.Path.Combine(path,filename)
However, this gives me a
"Message":"The given path\u0027s format is not supported.","StackTrace":" at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)\r\n at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)\r\n at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)\r\n at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, AccessControlActions...... and so on
I have tried modifying the rights to the TEMP folder, so that NETWORK SERVICES has rights..
Any ideas?
Your path contains an invalid character. Unicode code is 0027 which is a single quote "'" so you need to check where you are adding a single quote to the path.