I am working on debuging some logic and wanted to see if there is a way I can display this full list?
Cache.Select(Cache => Cache.Id.ToString());
{System.Linq.Enumerable.WhereSelectListIterator<OrderTemplateTool.Data.Dictionary, string>}
[0]: "4c5d3244-40cf-4ee2-a874-3f269b441a6d"
[1]: "2873049b-968a-4c9e-977f-38a8f14a35b6"
[2]: "272e63d0-494e-4d61-b621-c70a137b4b93"
....
[98]: "3f021aae-d54f-4d23-a257-c507b14ee46c"
[99]: "8b54508f-d6b4-4ced-ab58-5d3d3815d7bd"
< More... (The first 100 of 209 items were displayed.) >
Related
run into an interesting one today.
I have a bunch of code in C# that creates uses Powershell via a RunspacePool.
I feed it commands and it outputs exactly what Powershell would output if you ran Powershell on it's own, each line is a new entry in a List.
The strange thing is, today when trying the "Test-NetConnection" command in the program it has inconsistent results.
Command:
Test-NetConnection -ComputerName 'D123' -InformationLevel Detailed
D123 is a Windows 7 VM on the same network
Below you can see two results, it appears to be a 50% chance of getting either:
Count = 32
[0]: "ComputerName : D123"
[1]: "RemoteAddress : fe80::9503:8d01:d690:6c0a%14"
[2]: "PingSucceeded : True"
[3]: "PingReplyDetails : System.Net.NetworkInformation.PingReply"
[4]: "TcpClientSocket :"
[5]: "TcpTestSucceeded : False"
[6]: "RemotePort : 0"
[7]: "TraceRoute :"
[8]: "Detailed : True"
[9]: "InterfaceAlias : Internal"
[10]: "InterfaceIndex : 14"
[11]: "InterfaceDescription : Intel(R) 82574L Gigabit Network Connection #2"
[12]: "NetAdapter : MSFT_NetAdapter (CreationClassName = "MSFT_NetAdapter", DeviceID ="
[13]: ""{FDA85168-53B0-4F24-ABEB-BDC9F3A29958}", SystemCreationClassName = "CIM_NetworkPort","
[14]: "SystemName = "WIN-IAJUP1S3FL9.testdomain.com")"
[15]: "NetRoute : MSFT_NetRoute (InstanceID = "poB:DD9#?55"
[16]: "?55DD55"
[17]: "")"
[18]: "SourceAddress : MSFT_NetIPAddress (Name = "poB:DDl:pBD?:lDpC:mDmp?o/"
[19]: "?55"
[20]: "?55"
[21]: "55"
[22]: "", CreationClassName = "","
[23]: "SystemCreationClassName = "", SystemName = "")"
[24]: "NameResolutionSucceeded : True"
[25]: "BasicNameResolution : {}"
[26]: "LLMNRNetbiosRecords : {}"
[27]: "DNSOnlyRecords : {}"
[28]: "AllNameResolutionResults :"
[29]: "IsAdmin : True"
[30]: "NetworkIsolationContext : Private Network"
[31]: "MatchingIPsecRules :"
Or
Count = 9
[0]: "ComputerName : D123"
[1]: "RemoteAddress : fe80::9503:8d01:d690:6c0a%14"
[2]: "AllNameResolutionResults : 172.16.0.10"
[3]: "fe80::9503:8d01:d690:6c0a"
[4]: "InterfaceAlias : Internal"
[5]: "SourceAddress : fe80::b0f8:20b:f90c:cf3e%14"
[6]: "NetRoute (NextHop) : ::"
[7]: "PingSucceeded : True"
[8]: "PingReplyDetails (RTT) : 0 ms"
The second block is what it should be returning, it is also what the command shows when running on Powershell.
What i'd like to know is why it is returning so many values, from the looks of it it's returning results for all members in the command and not just the op level ones (if that makes sense, look here: Working with .NET properties in Power Shell), but I have absolutely no idea why.
EDIT1: The blocks of output are copy+pastes from Visual Studio, so the Count = 32 is how many lines Powershell passed back and the [number] is the List position.
EDIT2: It seems that the more details is coming from adding " | select *" to the command, this is strange though because none of my code does this and it gets the additional details 50% of the time.
Thanks to the help of Veefu and John I looked into my code more.
Unsure why it does this, but whenever I had the Powershell code run in the main Window Load event it would affect all subsequent executions of the same Powershell command.
When moved to a different section of the code it behaved as expected.
Unsure why this was happening but selecting specific properties from the Powershell output is more consistent, so to anyone who looks at this I'd suggest doing as Veefu said in the comments.
It's needed to select the second item from the drop-down menu that is hidden by default. The problem it that it works fine in Fire Fox 41 browser but not in Internet Explorer 11. I'm using Selenium Web Driver with C#, nUnit in Visual Studio 2010. Tests are executed on remote VM with Selenium Server and IEDriver.
HTML looks like:
<ul id="CVC" class="buttonMenu" style="visibility: hidden; left: 183px;">
<li class="menuItem">First</li>
<li class="menuItem">Second</li>
<li class="menuItem">Third</li>
</ul>
I have C# code that works only in FireFox:
var menu = wd.FindElement(By.Id("CVC"));
var menuLi = menu.FindElements(By.TagName("li"));
menuLi[1].Click();
wd.FindElement(By.Id("TITLE")).SendKeys("blabla"); //continue to work with appeared pop-up
wd.FindElement(By.Id("CVC_OK")).Click();
When I run test in Internet Explorer an error appears:
Test Name: Bookmark
Test FullName: EEE.Tests.BT.BB
Test Source: d:\Selenium\Automation\EEEAutomation\EEEAutomation\Tests\BT.cs : line 19
Test Outcome: Failed
Test Duration: 0:00:39.319
Result Message: OpenQA.Selenium.ElementNotVisibleException : Cannot click on element (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 35 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'wkqacl0801', ip: '10.101.6.104', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:39901/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 6f09c88a-bd73-4cab-9312-0587c8345023
Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at EEE.Tests.SubTests.CreateBBSubTest.Execute(IWebDriver wd) in d:\Selenium\Automation\EEEAutomation\EEEAutomation\Tests\SubTests\CreateBBSubTest.cs:line 103
at EEE.Tests.BT.BB() in d:\Selenium\Automation\EEEAutomation\EEEAutomation\Tests\BT.cs:line 54
Does anyone know how to make it worked in Internet Explorer 11?
Not sure if IE should be considered as a real browser. In any case I reread your problem, it seems that you expect IE to work like a browser on click event. In that case you might want to help it along :
using (var wd = new InternetExplorerDriver(
new InternetExplorerOptions {EnableNativeEvents = false}))
{
//your code
}
I figured out the solution by using JavaScript. I'm not sure that this is the best solution but at least it works not only in FF, but also in IE browser:
((IJavaScriptExecutor)wd).ExecuteScript("$('#CVC li:eq(1)').click()");
wd.FindElement(By.Id("TITLE")).Clear();
wd.FindElement(By.Id("TITLE")).SendKeys("blabla");
wd.FindElement(By.Id("CVC_OK")).Click();
This worked for me:
_driver.FindElement(By.Id("IdOfControl")).SendKeys(value);
I'm looking for a way (in java, c#..) to get the time when people speak in a video file (even in a movie).
I don't need to know the accurate words, just the time.
Output example:
00:03 - 01:03 (someone spoke for a minute),
03:00 - 06:12 (someone spoke again),
.
.
.
I have found Sphinx (written in java): http://cmusphinx.sourceforge.net/
but couldn't get it to recognize properly.
Any ideas?
Thanks.
EDIT:
This is what I've tried in sphinx (very basic):
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);
recognizer.startRecognition(somefile);
SpeechResult result;
while ((result = recognizer.getResult()) != null) {
System.out.println(result);
}
recognizer.stopRecognition();
There were only 3 results (there should be allot more).
EDIT2:
well, I tried this on a song in my computer:
https://www.assembla.com/code/sonido/subversion/nodes/12/sphinx4/src/sphinx4/edu/cmu/sphinx/tools/endpoint/Segmenter.java
This is the output:
DataStartSignal: creation time: 1399716763914
SpeechStartSignal
DoubleData: 44100Hz, first sample #: 8820, collect time: 200
DoubleData: 44100Hz, first sample #: 9261, collect time: 210
.....
DoubleData: 44100Hz, first sample #: 1745037, collect time: 39570
SpeechEndSignal
SpeechStartSignal
DoubleData: 44100Hz, first sample #: 1894536, collect time: 42960
......
Two Problems:
1. My goal is to be able to do it on movies. It works on audio files (.wav)
2. I'm not sure it works well. As you can see, the output says the speech started after 200 milliseconds, where actually it started after 3 seconds at least (the song is 'Bee Gees - How Deep Is Your Love').
I have found Sphinx (written in java): http://cmusphinx.sourceforge.net/ but couldn't get it to recognize properly.
Like you said, you do not need to recognize. To get only voice activity detection in Java with times see the segmenter class edu.cmu.sphinx.tools.endpoint.Segmenter
I am saving some of the rendered html of a web site by overriding the Render method and using HtmlAgilityPack. Here is the code:
protected override void Render(HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new StringWriter()))
{
base.Render(htmlwriter);
string output= htmlwriter.InnerWriter.ToString();
var doc = new HtmlDocument();
doc.LoadHtml(output);
doc.Save(currDir + "\\" + reportDir + "\\dashboardTable.html");
}
}
However, some process does not let go of the saved file and I am unable to delete it from the server. Does anyone know of an HtmlAgilityPack issue that would cause this?
Any advice is appreciated.
Regards.
EDIT:
I have tried both of the methods suggested. I can't tell if they are the solution yet because my app is frozen on the server due to the files I can't delete. However, when I use these solutions on my own machine, the rendered HTML does not save as an HTML table anymore but rather like this:
INCIDENT MANAGEMENT
Jul '12 F'12
Trend F'12 2011
(avg)
Severe Incidents (Sev1/2): 3 2.1 4.16
Severe Avoidable Incidents (Sev1/2): 1 1.3 1.91
Incidents (Sev3): 669 482 460.92
Incidents (Sev4) - No business Impact: 1012 808 793
Proactive Tickets Opened: 15 19.3 14
Proactive Tickets Resolved/Closed: 14 17.3 11
CHANGE MANAGEMENT
Total Planned Changes: 531 560 583.58
Change Success Rate (%): 99.5 99.4 99
Non-Remedial Urgent Changes: 6 11 47.08
PROBLEM MANAGEMENT
New PIRs: 2 1.4 2
Closed PIRs: 0 2 3
Overdue Action items: 2 3.2 0
COMPLIANCE MEASUREMENTS
Jul Trend Jun
Total Number of Perimeter Devices: 250 258
Perimeter Devices - Non Compliant: 36 31
Total Number of Internal Devices: 6676 6632
Internal Devices - Non Compliant: 173 160
Unauthorized Perimeter Changes: 0 0
Unauthorized Internal Changes 0 0
LEGEND
ISP LINKS
July June Trend
SOC CPO DRP SOC CPO DRP
40% 34% 74% 39% 35% 74%
BELL MPLS HEAD ENDS
July June Trend
SOC CPO SOC CPO
8% 5% 7% 10% 8% 5.5% 7% 10%
ENTERPRISE NETWORK (# of issues called out)
July June Trend
CORE FW/DMZ CORE FW/DMZ
1 0 1 0
US & INTL (# of issues called out)
July June Trend
US Intl US Intl
2 2 2 3
LINE OF BUSINESS BELL WAN MPLS
<> 50%-65% >65% <> 50%-65% >65% Trend
Retail: 2272 0 1 2269 4 0
Business Banking: 59 1 0 60 0 0
Wealth: 122 2 0 121 2 1
Corporate: 51 0 0 49 2 0
Remote ATM: 280 0 0 280 0 0
TOOLS
Version Currency Vulnerability Status Health Status
Key Messages:
where only the text data has been saved and all of the HTML and CSS is missing. If I just use doc.Save() I get an exact representation of the table as it displays on the website.
Try this instead. Maybe the Save method isn't closing the underlying stream.
using( FileStream stream = File.OpenWrite( currDir + "\\" + reportDir + "\\dashboardTable.html" ) ){
doc.Save(stream);
stream.Close();
}
Edit
Per #L.B's comments it appears that HtmlAgilityPack does use a using block as in my example so it will be ensuring that the stream gets closed.
Thus as I suggested at the end of my original answer this must be a server environment problem
Original Answer
This may be some sort of bug with HtmlAgilityPack - you may want to report it to the developers.
However to eliminate that possibility you may want to consider explicitly controlling the creation of the StreamWriter for the file so you are explicitly closing it yourself. Replace this line:
doc.Save(currDir + "\\" + reportDir + "\\dashboardTable.html");
With the following:
using (StreamWriter fileWriter = new StreamWriter(currDir + "\\" + reportDir + "\\dashboardTable.html"))
{
doc.Save(fileWriter);
fileWriter.Close();
}
If the issue still persists even with this change then that would suggest an issue with your server environment rather than an issue with HtmlAgilityPack. Btw to test if this change makes a difference you should start from a clean server environment rather than one where you are already having issues deleting the file in question.
I have a web site that displays a table along with some buttons, navigation tabs, etc. Using HtmlAgilityPack I would like to save only the node containing the table (a div) to a .html file. I have been experimenting with this code:
string dashboard = doc.DocumentNode.SelectSingleNode("//div[#id='Dashboard']").InnerHtml;
doc.LoadHtml(dashboard);
doc.Save(currDir + "\\dashboardOutputFile.html");
But this only preserves the text components of the table and none of its layout/display information. I have tried adding a Doctype declaration as well as enclosing html and body tags to the dashboard string but it has no effect.
Any advice is appreciated.
Regards.
EDIT:
I should be more explicit. I am capturing the html of my page by overriding the Render method:
protected override void Render(HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new StringWriter()))
{
base.Render(htmlwriter);
string renderedContent = htmlwriter.InnerWriter.ToString();
var doc = new HtmlDocument();
doc.LoadHtml(renderedContent);
try
{
string dashboard = doc.DocumentNode.SelectSingleNode("//div[#id='Dashboard']").InnerHtml;
dashboard = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><br><html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body><div><br>" + dashboard + "<br></div></body></html>";
doc.LoadHtml(dashboard);
doc.Save(currDir + "\\dashboardOutputFile.html");
}
catch (NullReferenceException ex)
{
// Do nothing.
}
writer.Write(renderedContent);
}
}
To the best of my knowledge the string "dashboard" should contain a complete HTML page after this. However the resulting .html file displays like this:
INCIDENT MANAGEMENT
Jun '12 F'12
Trend F'12 2011
(avg)
Severe Incidents (Sev1/2): 2 2 4.16
Severe Avoidable Incidents (Sev1/2): 1 1.3 1.91
Incidents (Sev3): 600 459 460.92
Incidents (Sev4) - No business Impact: 869 782 793
Proactive Tickets Opened: 24 20 14
Proactive Tickets Resolved/Closed: 22 17.8 11
CHANGE MANAGEMENT
Total Planned Changes: 623 564 583.58
Change Success Rate (%): 99.9 99.4 99
Non-Remedial Urgent Changes: 5 11.4 47.08
PROBLEM MANAGEMENT
New PIRs: 1 1.4 2
Closed PIRs: 1 2.3 3
Overdue Action items: 2 3.4 0
COMPLIANCE MEASUREMENTS
Jun Trend May
Total Number of Perimeter Devices: 258 242
Perimeter Devices - Non Compliant: 31 7
Total Number of Internal Devices: 6632 6521
Internal Devices - Non Compliant: 160 38
Unauthorized Perimeter Changes: 0 0
Unauthorized Internal Changes 0 0
LEGEND
ISP LINKS
June May Trend
SOC CPO DRP SOC CPO DRP
39% 35% 74% 38% 35% 73%
BELL MPLS HEAD ENDS
June May Trend
SOC CPO SOC CPO
8% 5.5% 7% 10% 7.5% 5% 6% 10%
ENTERPRISE NETWORK (# of issues called out)
June May Trend
CORE FW/DMZ CORE FW/DMZ
1 0 1 0
US & INTL (# of issues called out)
June May Trend
US Intl US Intl
2 3 2 3
LINE OF BUSINESS BELL WAN MPLS
<> 50%-65% >65% <> 50%-65% >65% Trend
Retail: 2269 4 0 2271 2 0
Business Banking: 60 0 0 51 1 0
Wealth: 121 2 1 111 3 2
Corporate: 49 2 0 51 1 1
Remote ATM: 280 0 0 279 0 0
TOOLS
Version Currency Vulnerability Status Health Status
Key Messages:
Only the text of the table cells is being displayed. There is no table layout, no background colours, etc. Even when I copy the file into JSFiddle it displays like this. What am I missing to make this a complete HTML page?
There's probably a css file linked into the original html not being read in your downloaded page.