I'm trying to create an OPC UA - Client to read Data from an OPC - Server. I am using Softing .NET Toolkit for this. But the main problem is, that the Documentation is only for C# and I'm not very familiar with C#. I know, there are some C# -> VB.NET translater on the Internet, but they don't work very well for this code.
I need to translate the following Code to Visual Basic .NET. Could someone help me with this?
How is this "method" called with this brackets "{" ? Is this a method, to join an instance of the class?
const string StaticValueNodeID = "ns=3;i=10221";
const string StaticValueNodeID1 = "ns=3;i=10229";
const string StaticValueNodeID2 = "ns=3;i=10228";
List<ReadValueId> listOfNodes = new List<ReadValueId>()
{
new ReadValueId()
{
NodeId = new NodeId(StaticValueNodeID),
AttributeId = AttributeId.Value
},
new ReadValueId()
{
NodeId = new NodeId(StaticValueNodeID1),
AttributeId = AttributeId.Value
},
new ReadValueId()
{
NodeId = new NodeId(StaticValueNodeID2),
AttributeId = AttributeId.Value
}
};
Thank you very much in advance for your answer :)
Related
I need to convert the following Java code to C# but I couldn't find the equivalent of "SpanMultiTermQueryWrapper". Could you please help?
FuzzyQuery firstNameQuery = new FuzzyQuery(new Term("text", firstName), 2);
FuzzyQuery lastNameQuery = new FuzzyQuery(new Term("text", lastName), 2);
SpanQuery[] clauses = new SpanQuery[] {
new SpanMultiTermQueryWrapper<MultiTermQuery>(firstNameQuery),
new SpanMultiTermQueryWrapper<MultiTermQuery>(lastNameQuery)
};
SpanNearQuery spanNearQuery = new SpanNearQuery(clauses, 3, false);
SpanMultiTermQueryWrapper and MultiTermQuery are both available on Lucene.Net 4.8.0-beta00004.
If you need support in earlier versions of Lucene.Net, you can probably just grab the source code from the above links and any dependencies and drop them into a library for your applications.
Even though I have already changed the API Compatibility Level from .NET 2.0 Subset to .NET 2.0 in Edit->Project Settings->Player under Optimizations, upon upgrading to Unity 5.3.0 I am still getting the following two error messages:
`System.IO.File' does not contain a definition for `AppendText'
`System.IO.File' does not contain a definition for `CreateText'
They refer to the following code snippets:
using(StreamWriter writer = File.CreateText(saveFilePath))
{
string sLine = "time;joint;pos_x;pos_y;poz_z";
writer.WriteLine(sLine);
}
using(StreamWriter writer = File.AppendText(saveFilePath))
{
string sLine = string.Format("{0:F3};{1};{2:F3};{3:F3};{4:F3}", Time.time, (int)joint, jointPos.x, jointPos.y, jointPos.z);
writer.WriteLine(sLine);
}
How do I resolve this?
Are you tried this case?
using (var f = new StreamWriter("file path", true))
{
f.WriteLine("appended text");
f.Flush();
}
As a newbie to Lucene.Net/Lucene and to C# I was able to put some lines of code and have a search running.
Now I want to get a snippet of the found area back. I have found below code but Visual Studio keeps telling me that a) "Searcher does contain a definition of getIndexReader" and b) "ScoreDoc does not contain a definition of doc" -and I don't get the point where the problem is!
Is there anybody out there who can help.
I am using Lucene.Net 3.0.3 and Lucene Contrib 3.0.3 on Visual Studio 2010 Express.
See the code I have below.
Thanks for your help!
RC
IndexReader indexReader = IndexReader.Open(directory, true);
Searcher indexSearch = new IndexSearcher(indexReader);
var queryParser = new QueryParser(Version.LUCENE_30, "text", analyzer);
var query = queryParser.Parse("\"system AKZ\"~10");
Console.WriteLine("Searching for: " + query);
TopDocs hits = indexSearch.Search(query,500);
/// Highlighter
FastVectorHighlighter fvHighlighter = new FastVectorHighlighter(true, true);
for (int i = 0; i < hits.ScoreDocs.Length; i++)
{
string bestfragment fvHighlighter.GetBestFragment(fvHighlighter.GetFieldQuery(query),indexSearch.getIndexReader(), hits.ScoreDocs[i].doc, "text", 20);
MessageBox.Show(bestfragment);
}
Console.WriteLine("Results Found: " + hits.TotalHits);
I would pull out something like ILSpy to examine what methods actually are available.
This is just a problem with the case of the method names. It's GetIndexReader() for example not getIndexReader(). You are probably basing this on docs for the Java implementation.
in Lucene.net this method's name is IndexReader.
Is there a difference between these two things. I am trying to move some reports from a local server to a dev server and I know that we have installed the redist on the dev server, but am still having problems getting the report to run. Is the runtime separate I come accross different sites mentioning both things but havent been able to tell if they are talking about the same thing
*Edit - posting code to see if as dotjoe suggested I have incorrectly labled my report path. the database connection is returned from a method to a string array reportString so that is what that array is.
<CR:CrystalReportViewer ID="CrystalReportViewer2" runat="server"
AutoDataBind="True" Height="50px" Width="350px" ReuseParameterValuesOnRefresh="True" ToolbarImagesFolderUrl="~/images/reportViwerImages"/>
ConnectionInfo myConnectionInfo = new ConnectionInfo();
myConnectionInfo.ServerName = reportString[1];
myConnectionInfo.DatabaseName = reportString[0];
myConnectionInfo.UserID = reportString[2];
myConnectionInfo.Password = reportString[3];
string ReportPath = Server.MapPath("../../mdReports/CrystalReport.rpt");
CrystalReportViewer2.ReportSource = ReportPath;
ParameterField field1 = new ParameterField();
ParameterDiscreteValue val1 = new ParameterDiscreteValue();
val1.Value = hiddenFieldReportNumber.ToString();
field1.CurrentValues.Add(val1);
SetDBLogonForReport(myConnectionInfo);
private void SetDBLogonForReport(ConnectionInfo myConnectionInfo)
{
TableLogOnInfos myTableLogOnInfos = CrystalReportViewer2.LogOnInfo;
foreach (TableLogOnInfo myTableLogOnInfo in myTableLogOnInfos)
{
myTableLogOnInfo.ConnectionInfo = myConnectionInfo;
}
}
you have not load the report from the given Path.
Please see below link
I can send callback param(s) and it works perfectly as long as I am only sending some primitive types like String. But the same thing does not work for even the simplest POJO. PrimeFaces guide says that the RequestContext.addCallbackParam() method can handle POJOs and it coverts them into JSON. I don't know why it's not working in my case.
Has anybody done that?
Solution found! ---------------------------------------------------------------------
I did some research and found the answer to this question.
And the solution was to use some JSON library (right now I am using GSON) to convert Java objects to JSON objects.
new Gson().toJson(someJavaObj)
returns string. Just send the string as the param and on the client side using js' eval or some js library's function to turn that into JSON again.
Actually, it was pretty clean and simple.
Sorry I actually did not post the solution. Below is the my solution -
Action method in the backing bean -
public void retrievePieData() {
List<String> categories = new ArrayList<String>();
categories.add("Electronic");
categories.add("Food");
categories.add("Liguor");
categories.add("Stationary");
categories.add("Mechanical");
List<Integer> itemCounts = new ArrayList<Integer>();
itemCounts.add(5);
itemCounts.add(20);
itemCounts.add(1);
itemCounts.add(50);
itemCounts.add(10);
RequestContext reqCtx = RequestContext.getCurrentInstance();
reqCtx.addCallbackParam("categories", new Gson().toJson(categories));
reqCtx.addCallbackParam("itemCounts", new Gson().toJson(itemCounts));
}
PrimeFaces p:commandButton in the view -
<p:commandLink action="#{pieDataProvider.retrievePieData}" oncomplete="feedPieData(xhr, status, args);" value="Pie chart demo" update="pieData" />
Javascript function -
function feedPieData(xhr, status, args) {
var categories = eval('(' + args.categories + ')');
var itemCounts = eval('(' + args.itemCounts + ')');
options.xAxis.categories = categories;
var series = {
data: []
};
series.name = new Date().toString();
series.data = itemCounts;
options.series = [series];
chart = new Highcharts.Chart(options);
}
I would really appreciate and welcome any suggestion or opinion.
Thank you!