The update from my AIF Webservice for SalesAgreementHeader [AX 2012] fails - c#

Hello I've created a query with only the SalesAgreementHeader as table. Then I used the wizard to create a document aif webservice.
The webservice works fine, but the update always reports an "Invalid xml document." error.
This error is thrown by the method moveToNextElement in the class AxdBaseCreate.
The reason for the exception is, that
reader.fieldName() = AgreementClassification
and
_expectedElementName = AgreementRelationType.
How can I fix this? Or is there any good way to debug this?
Before I created the query with only the SalesAgreementHeader I had an more complex query and had the same error. Then I created a new one and reduced it to only the SalesAgreementHeader.
Update:
A haven't solved the problem yet, but I think the problem could be because SalesAgreementHeader extends the AgreementHeader and the field RelationType is not visible in the AOS, but if you look directly in the DB.
Update 2:
This is the call stack:
[s] \Classes\AxdBaseCreate\moveToNextElement 9
[s] \Classes\AxdBaseCreate\readSurrogateForeignKeyValue 37
[s] \Classes\AxdBaseCreate\readProperty 14
[s] \Classes\AxdBaseCreate\readProperties 122
[s] \Classes\AxdBaseUpdate\deserializeTopEntity 25
[s] \Classes\AxdBaseUpdate\deserializeDocument 131
[s] \Classes\AxdBaseUpdate\updateDocumentList 42
[s] \Classes\AxdBase\updateList 64
[s] \Classes\AifDocumentService\updateList 34
[s] \Classes\SalesAgreementService\update 4

Could you please provide code which you're using?
I have an assumption (based on the name of AgreementRelationType it looks like this is Enim ) that you're trying to update field based on enum. If this is the case, then I hope I can help you.
When you need to update enum use following approach:
//here is an example how to change Status on SalesTable
//as you may see when you change the value of enum you have to set boolean autogenerated field to "true".
//Name of such fields ends with suffix "Specified"
salesTable.SalesStatus = AxdEnum_SalesStatus.Invoiced;
salesTable.SalesStatusSpecified = true;
In advance I'd like to suggest you (in case you didn't do that) use following try..catch block. This will make your life easier.
try
{
//your code here
}
catch (System.ServiceModel.FaultException<SalesOrderDelete.SalesOrderDeleteTcpNet.AifFault> aifFaults) // This code catches error messages even when "Logging mode = Logging is disabled" on Inbound port
{
SalesOrderDelete.SalesOrderDeleteTcpNet.InfologMessage[] infologMessageList = aifFaults.Detail.InfologMessageList;
foreach (SalesOrderDelete.SalesOrderDeleteTcpNet.InfologMessage infologMessage in infologMessageList)
{
Console.WriteLine("Exception: " + infologMessage.Message + "\n");
}
Console.WriteLine("\nPress any key to quit.\n");
Console.ReadKey();
cl.Abort();
}

Related

How to write code in C #, to add new data to the database

Adding triplets to GraphDB
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://localhost:7200/sparql"), "http://localhost:7200/");
SparqlResultSet results = endpoint.QueryWithResultSet("PREFIX : <http://www.example.org/> INSERT DATA {:test :test :hhrh }");
why does not it work?
StardogConnector stardog = new StardogConnector("http://localhost:7200", "test", "admin", "posw");
stardog.Begin();
string query = "PREFIX : <http://www.example.org/>SELECT * WHERE {:" + line[0] + " ?k :" + line[1] + "}";
stardog.Query(query);
stardog.Commit();
another way, same problem. Created a DB on a lokalka
Yes, I also came to this conclusion, I use GraphDB for the first time. Well, how can I implement it with a file? I wrote such code.
IGraph g = new Graph();
string sql = "PREFIX : <http://www.example.org/> INSERT DATA {:test :test :hhrh }";
g.LoadFromFile("t.n3");
Object results = g.ExecuteQuery(sql);
here comes such an error
VDS.RDF.Parsing.RdfParseException
HResult = 0x80131500
Message = [InsertKeywordToken at Line 1 Column 36 to Line 1 Column 42] Unexpected Token encountered - expected a BASE / PREFIX directive or a Query Keyword to start a Query
Source = dotNetRDF
Stack trace:
in VDS.RDF.Parsing.SparqlQueryParser.ParseInternal (SparqlQueryParserContext context)
in VDS.RDF.Parsing.SparqlQueryParser.ParseInternal (TextReader input)
in VDS.RDF.Parsing.SparqlQueryParser.ParseFromString (String queryString)
in VDS.RDF.GraphExtensions.ExecuteQuery (IGraph g, String sparqlQuery)
in algorAutoText.Program.Main (String [] args) in C: \ Users \ Denis \ source \ repos \ algorAutoText \ algorAutoText \ Program.cs: line 43
judging by mistake, I supposedly did not add BASE / PREFIX. But he is in the request
Update and delete queries come through the /statements endpoint,
i.e. /repositories/{repository_id}/statements.
You can see the RDF4J server REST API here:
http://docs.rdf4j.org/rest-api/#_the_rdf4j_server_rest_api
When you use the DELETE or INSERT keywords you are doing a SPARQL Update, not a Query. SPARQL separates Query and Update into two separate specifications and most triple stores implement them as two separate endpoints (e.g. for security reasons).
To do an update from dotNetRDF into a triple store you have two options.
You can work directly with the SPARQL update endpoint in which case you will need to check the documentation for your triple store to find out how to create the URL for that - see https://github.com/dotnetrdf/dotnetrdf/wiki/UserGuide-Updating-With-SPARQL#remote-updates for details.
Alternatively if your triple store is one of the ones supported by dotNetRDF (Stardog and Sesame/GraphDB both are), then there are convenience wrappers that make this a bit easier - for more information about this please refer to https://github.com/dotnetrdf/dotnetrdf/wiki/UserGuide-Triple-Store-Integration#update

iText7: How to fix: One PdfTextFormField with two combs, SetValue No MaxLen Error

I have a PDF file with acroforms that I am trying to fill out using iText7. I am getting an error when there are two Comb fields with the same FieldName when I try to use field.SetValue("1234"). Is this a bug or am I missing something?
iText.Kernel.PdfException: 'No /MaxLen has been set even though the Comb flag has been set.'
Calling textField.GetMaxLen() shows the comb length set in Acrobat (10). Calling textField.SetMaxLen(10) before calling SetValue has no effect. Nor does SetMaxLen(10) with a RegenerateField() call after. Inspecting the pdfObject, I see the following:
{<</DA /Helv 12 Tf 0 g /FT /Tx /Ff 29360128 /Kids [28 0 R 29 0 R ] /MaxLen 10 /T CombTestField >>}
So I see the /MaxLen 10 entry, but I still get the error above.
The two widgets are Ctrl-C/Ctrl-V copies of each other. Both are combs of 10 chars.
var pdf = new PdfDocument(new PdfReader(inFile), new PdfWriter(outFile));
var form = PdfAcroForm.GetAcroForm(pdf, false);
var field = form.GetField("CombTestField");
if (field is PdfTextFormField textField)
{
var maxLen = textField.GetMaxLen();
if (maxLen == 10)
{
textField.SetValue("1234");
}
}
So I am getting the error with 2 comb widgets. I delete one of them and the problem goes away. I am working with a client's form, so cannot simply remove the second widget. Any fix or even workaround would be welcome.
EDIT: Here's the file in question. http://www.filedropper.com/combtest
EDIT2: iText 7.7.1.5
It's a known bug and it has just recently been fixed. A snapshot version including the fix is already available (7.1.6-SNAPSHOT). Although alternative workarounds should exist, I wouldn't recommend to consider them as a solution, because some other issues with forms processing have also been improved since 7.1.5. So please try out the snapshot :)

Reading CI Frequency In C# With NI USB-6363

Working LabVIEW Code
Attached above is LabVIEW code that I have successfully used in the past to read frequency data from a device. I also usually use the Start Task VI between my property node and while loop.
I am trying to code this in C#. So far I have successfully been able to code analog Output's and analog Input's on my device, USB-6363, (so I know I am able to write and read data from the device successfully with C#).
I have also used multimeters (Grainger link at bottom of post) to read frequency data (Orange Hz mode that the device is set to in the picture).
However, my C# code seems to be having issues reading the frequency data. My C# code is attached. When I try running this program I get the following error. This is the same error that I get when using the example program called 'MeasDigFreqBuffCont_ExtClk_ArmStart.2013'. The code I show is just creating the task, I do call the code later in my program in a different section and that is how I am getting the error.
------------------------------------------------- Begin Error Code -------------------------------------------------
{Error=-200077 Message="Requested value is not a supported value for
this property. The property value may be invalid because it conflicts
with another property.\n\nProperty:
NationalInstruments.DAQmx.CIChannel.FrequencyDivisor\nRequested Value:
1\nPossible Values: 4 to 4294967295\nChannel Name: Digital
Frequency\n\nTask Name: _unnamedTask<0>\n\nStatus Code: -200077"}
------------------------------------------------- End Error Code --------------------------------------------------
In the example program it asks for a sample clock source (A PFI channel from the device). However in the LabVIEW code it does not ask for this. Is this example maybe more in detail than what I am trying to do?
Task frequencyInput = new Task();
frequencyInput.CIChannels.CreateFrequencyChannel(
"Dev1/ctr0",
"Digital Frequency",
200,
15000,
CIFrequencyStartingEdge.Rising,
CIFrequencyMeasurementMethod.DynamicAveraging,
0.001,
1,
CIFrequencyUnits.Hertz
);
frequencyInput.CIChannels["Digital Frequency"].FrequencyTerminal = "/Dev1/PFI0";
CounterSingleChannelReader counterFreq = new CounterSingleChannelReader(frequencyInput.Stream);
double counterFreqData = counterFreq.ReadSingleSampleDouble();
txtPFI0.Text = Convert.ToString(counterFreqData);
FLUKE (R) Fluke-115 Compact - Basic Features Digital Multimeter, 14° to 122°F Temp. Range
Formatting the error message:
Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: NationalInstruments.DAQmx.CIChannel.FrequencyDivisor
Requested Value: 1
Possible Values: 4 to 4294967295
Task Name: _unnamedTask<0>
Status Code: -200077
According to the documentation, you are asking the device to use an invalid divisor. Change your 1 to a 4:
frequencyInput.CIChannels.CreateFrequencyChannel(
"Dev1/ctr0",
"Digital Frequency",
200,
15000,
CIFrequencyStartingEdge.Rising,
CIFrequencyMeasurementMethod.DynamicAveraging,
0.001,
/* here */ 4,
CIFrequencyUnits.Hertz
);
NI installs C# examples for DAQmx, and it includes one for measuring frequency:
C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET4.0\Counter\Measure Digital Frequency\MeasDigFrequency_LowFreq1Ctr\CS

Enumeration values for FaxJob.SetStatus method

Using Windows Fax Service, I am trying to cancel a fax from the Windows Fax Console. According to this worthless documentation I need to pass in a value JC_Delete which appears that it is some enumeration, however, the documentation fails to leave out what it is or how to get it.
I found another MSDN article stating in the last sentence that these JC values are just constants which the user defines. Finally, I found a forum post stating that it's just an enumeration in a C++ header file and the Microsoft guy showed the enumeration consisting of:
JC_UNKNOWN = 0
JC_DELETE = 1
JC_PAUSE = 2
JC_RESUME = 3
JC_RESTART = JC_RESUME
I just tried plugging in numbers, 0 or 1 since the method calls for an int and then I receive an exception
COM error:
the handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
Here is my bit of code. I am able to get the FaxJob object just fine. It's just calling the SetStatus() method that bombs.
var job = this.getFaxJobsInQueue().Where(j => j.JobId == JobId).Single();
job.SetStatus(1);
Arg!! Found the problem! It was very simple! I forgot to connect to the fax console. Apparently that is what the handle is invalid was indicating. My problem was in the method that returned all the jobs connected and disconnected. Once I had the FaxJob object, I was suppose to connect again. Here is my updated code:
var job = this.getFaxJobsInQueue().Where(j => j.JobId == JobId).Single();
this.objFaxServer.Connect(faxServerConnectionString);
job.SetStatus(1);
this.objFaxServer.Disconnect();

Linq 'Index was outside the bounds of the array' problem

In trying to setup a unit test for inserting an item into an SQL Server Express (2008) database using C# Linq I've encountered an error that is causing me some trouble. The Linq code is built using Visual Studio 2008.
The exception is thrown on a system running Windows XP SP2. The Linq works fine and the record is inserted appropriately on a system running Windows 7 Home Premium (64-bit).
I've dropped and re-created the database on the XP system. I've dropped and re-created the DAL and corresponding DBML on the XP system.
Other tables with unit tests for inserts to the same database work just fine.
Inserting a record into the table using a simple insert statement in SQL Server Management Studio works appropriately.
What should I look at to find the source of the problem? What should be done to resolve the problem?
Any insight as to what the error message is really trying to say would be greatly appreciated.
Error Message
System.IndexOutOfRangeException : Index was outside the bounds of the array.
Stack Trace
at
System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
at System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache`2.Find(Object[] keyValues)
at System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues)
at System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues)
at System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance)
at System.Data.Linq.ChangeProcessor.BuildEdgeMaps()
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges()
at nUnit.DAL.FacilityTests.AddFacility2() in C:\SVN\SVNRevenue360\Branches\Dev\Code\ProviderAdvantage\nUnit.CoreTests\Tests\DAL\FacilityTests.cs:line 50
Insert Code
[Test]
public void AddFacility2() {
string facilityname = "Test Facility";
try {
using (PA.Database.Revenue360DB db = new PA.Database.Revenue360DB(PA.DAL.DataAccess.ConnectionString)) {
db.Log = Console.Out;
PA.Database.Facility facility = new PA.Database.Facility();
facility.id = Guid.NewGuid();
facility.Name = facilityname;
facility.Street1 = "";
facility.Street2 = "";
facility.Street3 = "";
facility.City = "";
facility.State = "";
facility.Zip = "";
facility.Description = "";
db.Facilities.InsertOnSubmit(facility);
db.SubmitChanges(); // line 50
}
} catch (Exception ex) {
Console.WriteLine(ex.GetType().FullName + ": " + ex.Message);
Console.WriteLine(ex.InnerException == null ?
"No inner exception" :
ex.InnerException.GetType().FullName + ": " + ex.InnerException.Message);
throw;
}
}
I've looked at the following SO questions without insight as to what is causing this particular issue.
https://stackoverflow.com/questions/1087172/why-am-i-getting-index-was-outside-the-bounds-of-the-array
IndexOutOfRangeException on Queryable.Single
Strange LINQ Exception (Index out of bounds)
Take a look at this link.
Here are a few excerpts:
A common cause of this error is
associations pointing in the wrong
direction. (Something that is
extremely easy to do if editing the
model by hand, partly because the
association arrow pointer is in the
opposite end of where it would appear
in an ER diagram)
and
I was having the same problem and it
was due to the fact my primary key was
two columns instead of the traditional
one. (both guids). When I added a
third column that was the sole primary
key column, it worked.
UPDATE: Did some more poking around and found this SO post. Looks like it might have something to do with your DBML...
If the code is working on one machine and not working on another the problem should be somewhere outside. Please check if the .NET Framework version on Windows XP is the same as on Windows 7. Secondly, if its XP SP2 then the Operating System might be the cause because Microsoft has changed a lot in SP3. Also check if the database has same tables. Try to reproduce the problem on the same db, i.e. take backup from Win7 and restore it on the XP (of cause backup your data first). What else? Security permissions and connection string might have an impact too.

Categories

Resources