|
Um.
I think you need to rethink that one. "adminpassword192.168.123.123" probably isn't a valid domain (unless you buy a whole load of domains), and '@' is not a valid character in a domain name anyway.
What are you trying to achieve? Not "what are you trying to do?" but what are you doing that you think you need this?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You are adding the at sign in the wrong place, and also missing the colon between the username and password. Make life easier for yourself by using the built in UriBuilder Class (System)[^] which will format the final URL string correctly. You also need to be aware that not all websites allow this form of authorisation; you may need to use HTTP authorisation parameters.
|
|
|
|
|
You used to be able to pass the username and password in the URL by using:
http://username:password@host/
However, this was an extremely bad idea.
Microsoft removed support for this from Internet Explorer 6 back in 2004:
Microsoft Security Bulletin MS04-004 - Critical[^]
Internet Explorer does not support user names and passwords in Web site addresses (HTTP or HTTPS URLs)[^]
Firefox still supports it, but displays a warning message:
Network.http.phishy-userpass-length - MozillaZine Knowledge Base[^]
Chrome tried to deprecate the feature back in 2012, but it looks like they were forced to turn it back on:
123150 - Chrome 19 doesn't respect basic auth details embedded in the URL - chromium - Monorail[^]
Behaviour in other browsers will vary. You can test your browser with the following URL:
https://foo:bar@httpbin.org/basic-auth/foo/bar[^]
Also, your code isn't building the correct URL. Your need:
string mystring = "http://" + username + ":" + password + "@" + myip + "/command.htm?key=";
string mystring = string.Format("http://{0}:{1}@{2}/command.htm?key=", username, password, myip);
string mystring = $"http://{username}:{password}@{myip}/command.htm?key=";
Alternatively, use the UriBuilder class[^]:
UriBuilder builder = new UriBuilder();
builder.UserName = username;
builder.Password = password;
builder.Host = myip;
builder.Path = "/command.htm";
builder.Query = "key=";
string mystring = builder.ToString();
But, as I said, the result of opening that URL will depend on your default browser.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello ,
I have a situation where I need to jump to a specific location from tab 1 to tab 2's certain section. Here is the sample of my code.
<pre>@{
<div id="tabs-1"><fieldset class="vs"><legend>tab1</legend>
<a href="mypage/#tabs-2">click me 1</a>
<p>click me 2</p>
</fieldset></div>
<div id="tabs-2">
<fieldset class="vs"><legend>tab2</legend>
<p>test1 description</p>
<ul>
<li>This is a test 1.</li>
</ul>
<p>test2 description</p>
<ul>
<li>This is a test 2.</li>
</ul>
<p>test3 description</p>
<ul>
<li>This is a test 3.</li>
</ul>
<p>test4 description</p>
<ul>
<li>This is a test 4.</li>
</ul>
<p>test5 description</p>
<ul>
<li>This is a test 5.</li>
</ul>
<p>test6 description</p>
<ul>
<li>This is a test 6.</li>
</ul>
<p>test7 description</p>
<ul>
<li>This is a test 7.</li>
</ul>
<p>test8 description</p>
<ul>
<li>This is a test 8.</li>
</ul>
<p>test9 description</p>
<ul>
<li>This is a test 9.</li>
</ul>
<p>test10 description</p>
<ul>
<li>This is a test 10.</li>
</ul>
<p>test11 description</p>
<ul>
<li>This is a test 11.</li>
</ul>
<p>test12 description</p>
<ul>
<li>This is a test 12.</li>
</ul>
<p>test13 description</p>
<ul>
<li>This is a test 13.</li>
</ul>
<p>test14 description</p>
<ul>
<li>This is a test 14.</li>
</ul>
</fieldset>
</div>
}
Now how do i click "Click me 1" and go to the "tabs-2" and scroll down to "test14 description"?
Please help.
Thank you
Dhyanga
modified 13-Feb-17 13:21pm.
|
|
|
|
|
You'll need to add an id to any element that you want to be a navigation target.
<p id="test14">test14 description</p>
You then specify that ID in the URL:
<a href="mypage/#test14">click me 1</a>
How you ensure that tabs-2 will be visible when you navigate to an item within the tab depends the script / CSS you're using to create the tabs. For example, with Bootstrap, something like this should work:
$(function(){
$("#tabs").tab();
if (location.hash){
var target = $(":target");
if (!target.is(".tab-pane")){
target = target.closest(".tab-pane");
}
if (target.is(".tab-pane")){
$("#tabs").one("shown.bs.tab", function(){
$("html, body").animate({
scrollTop: $(":target").offset().top
}, "fast");
});
var id = target.prop("id");
$("a[data-toggle='tab'][href='#" + id + "']").tab("show");
}
}
});
NB: This question has nothing to do with C#. In future, please post in the correct forum.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Guys,
I need help to write application to constantly check and read xml data saved in specific folder on network and extract data to sql database.
|
|
|
|
|
So, what have you written so far? We don't know what you have done, or what errors your code has encountered, or even what you are stuck on. All you have done is tell us what your application should do.
This space for rent
|
|
|
|
|

import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class Dom
{
public static void main (String[] args)
{
String badnumber = "MPP";
int badnumberconverted;
try {
badnumberconverted = Integer.parseInt(badnumber);
}catch (NumberFormatException nfEx){
}
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("repeat.xml");
NodeList sampleIDs = doc.getElementsByTagName("Elements");
for(int i=0;i<sampleIDs.getLength();i++){
Node p = sampleIDs.item(i);
if(p.getNodeType() == Node.ELEMENT_NODE){
Element Elements = (Element) p;
String id = Elements.getAttribute("id");
NodeList nameList = Elements.getChildNodes();
for(int j=0;j<nameList.getLength();j++){
Node n = nameList.item(j);
if(n.getNodeType() == Node.ELEMENT_NODE){
Element name = (Element) n;
System.out.println("Elements" + id + ":" + name.getTagName()+ "=" + name.getTextContent());
}
}
}
}
}
catch (ParserConfigurationException e){
e.printStackTrace();
}
catch (SAXException e)
{
e.printStackTrace();
}
catch (IOException e){
e.printStackTrace();
}
}
public static String convert(String val)
{
double d = Double.parseDouble(val);
d = d/1000000;
return Double.toString(d);
}
}
|
|
|
|
|
Hi Peter,
This is what i have done so far. can only read xml data.
|
|
|
|
|
This is the C# forum. That code is Java.
This space for rent
|
|
|
|
|
please don't cross-post - you posted this in java - pick the best forum, stick to it, even if it's not 100%
btw - in c#, you can use 'TopShelf' as the basis for a Service - this might be worthwhile looking at NuGet Gallery | Topshelf.FileSystemWatcher 1.0.0.17
|
|
|
|
|
Suppose a data table can access 2003 such as fields execel file attachments, I want to query the warehouse group by name, bar code, goods, inventory, and then type the serial number, the results of its attachments write queries like? Attachments: http://www.mediafire.com/file/lv73f1usj5yqdk2/STTen.xls
|
|
|
|
|
You seem to have mistaken this for the Database forum. It's not - this is for C# questions. Please address your database questions in the right location.
This space for rent
|
|
|
|
|
I want to design the simply software that can convert the pdf files to the word files.
I use third part softwares to support my code. Third part software is sautinSoft.Pdffocus.
When I running my program, I find out a problem that can't convert the all of essay in pdf files to word files.
Can you tell me why I can't convert the all of essay in pdf files to word files? I have tried to check my program, but I can't find out any bugs in my program. I think it is very easy and simply function.
private void TransferFile(object sender, EventArgs e)
{
try
{
if (FileName.Text != "")
{
//PDFtoWord(FilePathFullName.Text, "Test");
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.OpenPdf(@"C:\Users\DavidLin\Downloads\db-fund.pdf");
f.ToWord(@"C:\Users\DavidLin\Downloads\test.doc");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
MessageBox.Show("Finally");
}
|
|
|
|
|
Member 12757695 wrote: Can you tell me why I can't convert the all of essay in pdf files to word files?
No, we can't. We simply don't have access to your system, or to the PDF files you are attempting to convert. So even if we wanted to, we couldn't run that code and get the same results you do - which means we can't tell you "do this and it'll fix it".
What I'd suggest is that you start with the authors of your conversion software: SDK to convert PDF to Word, DOCX, RTF, HTML, Excel, Text, XML, Images TIFF for C# and VB.Net[^] - it's a paid for package, so they should provide technical support and will know a lot more about their system than we will. Or possibly, the trial is limited in it's functionality, and you have hit that limit. In which case, you need to buy it to continue using it!
We can't tell - we just can't run your code under the same conditions you can.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
The problem is not with your code since your code doesn't do anything at all with the conversion, other than create an instance of a class that does all the work for you.
You have no choice but to get with the support people of the company that made that library and take up the issue with them.
|
|
|
|
|
We can't help you.
Member 12757695 wrote: Third part software is sautinSoft.Pdffocus.
Ask them they should know.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
I am trying to return a list from three tables which have been joined using LINQ. At the moment I can only get a list which contains data from one table instead of all three tables.
Below is my code
public List<string> GetProductDetails(string productId)
{
var db = new ProductContext();
IEnumerable<Employee> emps = db.Employees.ToList();
IEnumerable<Project> projs= db.Projects.ToList();
IEnumerable<Product> prods = db.Products.ToList();
var productionDetails = from e in emps
join prj in projs on e.EmployeeID equals prj.ProjectID
join prd in prods on e.EmployeeID equals prd.productID
where prd.productID == Convert.ToInt32(productId)
select new {employee = e.EmployeeName, project = prj.ProjectName , product = prd.ProductName };
return productionDetails.Select(m=>m.EmployeeName).ToList();
}
I would like the list to contain employee, project, and product.
modified 11-Feb-17 1:22am.
|
|
|
|
|
my first worries are :-
public List<string> GetProductDetails(string productId)
and
return productionDetails.Select(m=>m.EmployeeName).ToList();
why ?
I would (because I understand it if I do it this way)
a) define a 'prodDetails' POCO and use that instead of 'string' as the return list type,
b) do a select 'new prodDetails {employee = e.EmployeeName .... instead of using an anonymous type
c) remove the .Select in the return productionDetails clause
|
|
|
|
|
Hi, thank you so much for your response. Your solution would work great in most cases but what if the method is a RESTful WCF service method?
Normally I would return a string or a list of string from a RESTful WCF Service or a RESTful Web API method so that the data can be sent across the web.
If my method needs to return a complex type, how do I modify my method to make it work in a RESTful Service?
modified 11-Feb-17 7:04am.
|
|
|
|
|
put a 'wrapper' around GetProductDetails maybe GetProductDetailsAsJSON and convert the returned list to a JSON encoded string
using Newtonsoft.Json;
and then ....
string productId = string.Empty;
List<prodDetails> productionDetails = GetProductDetails(productId);
string ProductDetailsJSON = Newtonsoft.Json.JsonConvert.SerializeObject(productionDetails);
return ProductDetailsJSON;
[edit] obviously on the other end when the REST package/data is received you have to do something like :-
// assuming you have the REST Data in a string called 'json', pretty dumb, but its only an example
List<proddetails> productionDetails = Newtonsoft.Json.JsonConvert.DeserializeObject<list<proddetails>>(json);
[/edit]
|
|
|
|
|
Liagapi wrote: At the moment I can only get a list which contains data from one table instead of all three tables. You are already creating one. See the line "select new {employee.."
That would create a new anonymous type, and that would be harder to return
Liagapi wrote: I would like the list to contain employee, project, and product. Create a new class that can hold the results, and return a list of that specific class.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Liagapi wrote: IEnumerable<Employee> emps = db.Employees.ToList();
IEnumerable<Project> projs= db.Projects.ToList();
IEnumerable<Product> prods = db.Products.ToList();
Your code is loading the whole of those three tables into memory, before filtering for the specific product. That's going to be horribly inefficient.
Liagapi wrote: string productId
where prd.productID == Convert.ToInt32(productId)
Your code is going to throw an exception if you pass in any string that can't be converted to an integer. Instead, you should change your parameter to be an integer, so that your expectations are obvious to the caller.
Liagapi wrote: public List<string> GetProductDetails
If you want to return something other than a single string for each record, you're going to need to change the return type.
Liagapi wrote: join prj in projs on e.EmployeeID equals prj.ProjectID
join prd in prods on e.EmployeeID equals prd.productID
Those join columns don't look right to me. Double-check how your models are related.
public sealed class ProductDetails
{
public string employee { get; set; }
public string project { get; set; }
public string product { get; set; }
}
...
public List<ProductDetails> GetProductDetails(int productId)
{
using (var db = new ProductContext())
{
var productDetails = from e in db.Employees
join prj in db.Projects on e.EmployeeID equals prj.ProjectID
join prd in prods on e.EmployeeID equals prd.productID
where prd.productID == productId
select new { e.EmployeeName, prj.ProjectName, prd.ProductName };
return productDetails.AsEnumerable().Select(x => new ProductDetails
{
employee = x.EmployeeName,
project = x.ProjectName,
product = x.ProductName
}).ToList();
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you all for replying. The joins are correct and I was able to get the results I was looking for. I've learned a lot from this exercise and your responses to my post helped tremendously.
modified 12-Feb-17 12:53pm.
|
|
|
|
|
I am trying to implement a virtual trackpad (WPF or WInforms). Problem is that every time I touchdown or touchmove on the screen the mouse cursor goes under my finger. I can programatically move the cursor elsewhere but it becomes a tug-of-war with WIndows.
Any thoughts on resolving this?
Thanks
-----
Jack
|
|
|
|