Coding in VS-2012 Express for Web -- VB.Net with this code...
Diagnostics.Debug.WriteLine(vbTab + ".prpUID_REPORT = [{0}]", .prpUID_REPORT)
Diagnostics.Debug.WriteLine(vbTab + ".prpRV_HeaderDSName = [{0}]", .prpRV_HeaderDSName)
Diagnostics.Debug.WriteLine(vbTab + ".prpRV_HeaderDSId = [{0}]", .prpRV_HeaderDSId)
Diagnostics.Debug.WriteLine(vbTab + ".prpRV_ReportDSName = [{0}]", .prpRV_ReportDSName)
Diagnostics.Debug.WriteLine(vbTab + ".prpRV_ReportDSId = [{0}]", .prpRV_ReportDSId)
Diagnostics.Debug.WriteLine(vbTab + ".prpRV_ReportPath = [{0}]", .prpRV_ReportPath)
Results in this in the Immediate-window:
.prpUID_REPORT = [22]
dsetCustHeader: .prpRV_HeaderDSName = [{0}]
SDS_RptHeader: .prpRV_HeaderDSId = [{0}]
dsetReportContentAll: .prpRV_ReportDSName = [{0}]
SDS_RptData: .prpRV_ReportDSId = [{0}]
ssrsFleetCostSummary_FLA.rdlc: .prpRV_ReportPath = [{0}]
Notice that the first debug-line shows the text correctly .prpUID_Report = [22]. However, the next debug-lines show the "value" followed by part of the source code line. It appears that the substitution into {0} is faulty.
Any clues as to what may be causing this? I think the debug-source code is syntactically correct, since the first line (= [22]) works as expected but the other lines do not.
Your comments are welcome.
Debug.WriteLine(string,string) method call is different from
Debug.WriteLine(string,object[])
which may be why the first WriteLine statement is working while the rest isnt as the second parameter is possibly a string.
Please check the documentation here
Have you tried using an explicit String.Format() call to see if that makes any difference?
Diagnostics.Debug.WriteLine(String.Format("{0} .prpUID_REPORT = [{1}]",vbTab, .prpUID_REPORT))
Diagnostics.Debug.WriteLine(String.Format("{0} .prpRV_HeaderDSName = [{1}]",vbTab, .prpRV_HeaderDSName))
` Other code omitted for brevity `
It may simply be an issue of the improper method call of the Debug.WriteLine() method (i.e. expecting an array or an object and just receiving a string, which is triggering the wrong functionality).
Related
I trying to click on a button with UiAutomator, but receive error "androidx.test.uiautomator.UiObjectNotFoundException"
I tried to locate object in two ways.
UiObject cartButton = uiDevice.findObject(new Selector().resourceId("R.id.group_cart_add_button"));
UiObject2 cartButton = uiDevice.findObject(By.res(InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName(), "R.id.group_cart_add_button"));
Then I use cartButton.click() but both times I receive an error.
In hierarchy this object is exist
And when I try to find it in Evaluate tool, I can do it:
But if I try to click, I receive an error:
Why?
You can do the following:
String packageName = "your-app-package-name"
String fullCartButtonResourceId = packageName + ":id/group_cart_add_button";
UiObject2 cartButton = mDevice.findObject(By.res(uk));
or
UiObject cartButton = findObject(new UiObject(new UiSelector().resourceId(fullCartButtonResourceId));
I have script that is taking a HTMLElement and the css.top and css.marginLeft of an element which refuses to set the properties in TypeScript.
here's my code:
let moveable1: HTMLElement = document.getElementsByClassName('moveable1')[0] as HTMLElement;
Here's how I'm getting the values and "trying" to set the properties.
console.log("**style.top** = " + (moveable1.style.top =
String((+this.chatScrollTop + +this.boxScrollTop).toFixed(0))));
console.log("**style.marginLeft** = " + (moveable1.style.marginLeft = String((+this.chatScrollLeft + +this.boxScrollLeft).toFixed(0))));
moveable1.style.top = String(moveable1.style.top);
moveable1.style.marginLeft = String(moveable1.style.marginLeft);
What's happening is:
moveable1.style.marginLeft and moveable1.style.top ALWAYS equals ""
I don't understand.
The console logs are reporting the correct values
style.top = 69
style.marginLeft = 100
top: **<<<=== "EMPTY"** and should be 69
marginLeft: **<<<=== "EMPTY"** and should be 100
Thoughts, anyone?
UPDATE:
Zeh suggested the solution:
I modified it a wee bit...
let top = +this.chatScrollTop + +this.boxScrollTop;
const marginLeft = this.chatScrollLeft + this.boxScrollLeft;
moveable1.style.top = top.toFixed(0) + "px";
moveable1.style.marginLeft = String(parseInt(marginLeft).toFixed(0)) + "px";
console.log("top: " + moveable1.style.top);
console.log("marginLeft: " + moveable1.style.marginLeft);
THANK YOU ZEH!
You're setting a style property to a number and then trying to re-read and convert it to a string. This doesn't work; top (et al) cannot be numbers therefore they're kept at their previous value("").
Also, you need units ("px", "pt", etc) when setting a style, otherwise it won't set either, even if it's a string. Hence when you try converting them from number to string you get another blank string.
// This returns 1
console.log(document.body.style.top = 1);
// Nevertheless, it didn't work, since this returns ""
console.log(document.body.style.top);
This is not a TypeScript problem, this is a JavaScript (rather, a DOM) "problem".
My suggestion is to simplify this code. It's not just hard to read, it's doing a lot that it shouldn't be doing - unnecessary conversions, depending on assignment side effects, etc.
Something like this should work:
const top = this.chatScrollTop + this.boxScrollTop;
const marginLeft = this.chatScrollLeft + this.boxScrollLeft;
moveable1.style.top = top.toFixed(0) + "px";
moveable1.style.marginLeft = marginLeft.toFixed(0) + "px";
Is there any way to compile Underscore.js templates on the server and get the Closure compiler to work with the generated code?
The main problem is that _.template:
_.template = function(str, data) {
var c = _.templateSettings;
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(obj||{}){__p.push(\'' +
str.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(c.interpolate, function(match, code) {
return "'," + code.replace(/\\'/g, "'") + ",'";
})
.replace(c.evaluate || null, function(match, code) {
return "');" + code.replace(/\\'/g, "'")
.replace(/[\r\n\t]/g, ' ') + "__p.push('";
})
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
+ "');}return __p.join('');";
var func = new Function('obj', tmpl);
return data ? func(data) : func;
};
generates JavaScript with a with-statement in it. The two obvious routes are:
modify Underscore.js's _.template not to generate withs
coerce Closure into playing nice
Is the second option possible?
Generally, the JS engines perform better without "with", so if generating it without "with" is an option that is likely the best solution.
Otherwise your options depend on whether you are hoping to using Closure Compilers ADVANCED mode. In SIMPLE mode, the compiler won't rename your properties on the template, and will assume that any undeclared variable are globals. So as long are your template object isn't causing any local variables to be shadowed it might "just work".
I'm trying to parse an RSS feed using LINQ to Xml
This is the rss feed:
http://www.surfersvillage.com/rss/rss.xml
My code is as follows to try and parse
List<RSS> results = null;
XNamespace ns = "http://purl.org/rss/1.0/";
XNamespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
XDocument xdoc = XDocument.Load("http://www.surfersvillage.com/rss/rss.xml");
results = (from feed in xdoc.Descendants(rdf + "item")
orderby int.Parse(feed.Element("guid").Value) descending
let desc = feed.Element("description").Value
select new RSS
{
Title = feed.Element("title").Value,
Description = desc,
Link = feed.Element("link").Value
}).Take(10).ToList();
To test the code I've put a breakpoint in on the first line of the Linq query and tested it in the intermediate window with the following:
xdoc.Element(ns + "channel");
This works and returns an object as expect
i type in:
xdoc.Element(ns + "item");
the above worked and returned a single object but I'm looking for all the items
so i typed in..
xdoc.Elements(ns + "item");
This return nothing even though there are over 10 items, the decendants method doesnt work either and also returned null.
Could anyone give me a few pointers to where I'm going wrong? I've tried substituting the rdf in front as well for the namespace.
Thanks
You are referencing the wrong namespace. All the elements are using the default namespace rather than the rdf, so you code should be as follow:
List<RSS> results = null;
XNamespace ns = "http://purl.org/rss/1.0/";
XDocument xdoc = XDocument.Load("http://www.surfersvillage.com/rss/rss.xml");
results = (from feed in xdoc.Descendants(ns + "item")
orderby int.Parse(feed.Element(ns + "guid").Value) descending
let desc = feed.Element(ns + "description").Value
select new RSS
{
Title = feed.Element(ns + "title").Value,
Description = desc,
Link = feed.Element(ns + "link").Value
}).Take(10).ToList();
I need help with the code below.
I try to convert a AutoCAD file from the format dwg to the format dwf.
Then, the dwf file is downloaded and opened on the client computer using a java applet.
The command used to convert the dwg file on the command-line is:
C:\inetpub\wwwroot\COR-Basic\cadviewer\converter\ax2008.exe -i="C:\inetpub\wwwroot\test\container\DU38_EG00_070116.dwg" -o="C:\inetpub\wwwroot\COR-Basic\cadviewer\files\DU38_EG00_070116.dwf" -f=dwf -model -text
this works when I enter the command text in cmd.exe.
But when I call it from my asp.net application, it only starts the process, but the process never ends...
I've tried adding an additional user, have given this user full permission, and full permissions on wwwroot, but it still doesn't work.
Anybody knows what I'm doing wrong, or how I could do it in another way?
If System.IO.File.Exists(strDWGlocation) Then
Dim psiProcessSettings As Diagnostics.ProcessStartInfo = New Diagnostics.ProcessStartInfo
psiProcessSettings.FileName = strApplicationPath
psiProcessSettings.Arguments = " -i=""" & strDWGlocation & """ -o=""" & strOutputLocation & """ -f=dwf -model -text"
'ST-LAPTOP\converter
psiProcessSettings.UserName = "converter"
psiProcessSettings.Password = secureString
'StefanSteiger.Debug.MsgBox("Input location:" + strDWGlocation)
'StefanSteiger.Debug.MsgBox("Output location:" + strOutputLocation)
Response.Write("<h1>Argument1: " + psiProcessSettings.Arguments + "</h1>")
Response.Write("<h1>Pfad1: " + psiProcessSettings.FileName + "</h1>")
'psiProcessSettings.RedirectStandardInput = True
psiProcessSettings.RedirectStandardError = True
psiProcessSettings.RedirectStandardOutput = True 'Redirect output so we can read it.
psiProcessSettings.UseShellExecute = False 'To redirect, we must not use shell execute.
'psiProcessSettings.CreateNoWindow = True ' don't create a window
Dim pConverterProcess As Diagnostics.Process = New Diagnostics.Process
pConverterProcess = Diagnostics.Process.Start(psiProcessSettings) 'Create the process.
pConverterProcess.Start() 'Execute the process.
'Response.Write("<h1>" + Replace(pConverterProcess.StandardOutput.ReadToEnd(), vbCrLf, "<BR />") + "</h1>") 'Send whatever was returned through the output to the client.
'pConverterProcess.CancelOutputRead()
'pConverterProcess.CancelErrorRead()
'pConverterProcess.StandardInput.Close()
'Wait for the process to end.
'pConverterProcess.WaitForExit()
pConverterProcess.Close()
'Dim iExitCode As Integer = pConverterProcess.ExitCode()
pConverterProcess.Dispose()
Else
MyNamespace.Debug.MsgBox("No such file.")
End If
This is my code that does a similar thing, and it works!
process.StartInfo.FileName = toolFilePath;
process.StartInfo.Arguments = parameters;
process.StartInfo.UseShellExecute = false; // needs to be false in order to redirect output
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardInput = true; // redirect all 3, as it should be all 3 or none
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(toolFilePath);
process.StartInfo.Domain = domain;
process.StartInfo.UserName = userName;
process.StartInfo.Password = decryptedPassword;
process.Start();
output = process.StandardOutput.ReadToEnd(); // read the output here...
process.WaitForExit(); // ...then wait for exit, as after exit, it can't read the output
returnCode = process.ExitCode;
process.Close(); // once we have read the exit code, can close the process
Why have you commented out the WaitForExit()?
You could try setting EnableRaisingEvents to true as well.
In my experience, the Process class is quite difficult to work with when reading the standard output, try removing any code that attempts to redirect and read output