|
Are you sure the Surface Pro is configured correctly for Dns?
|
|
|
|
|
It's strange Richard because I can ping it from the command line on the Surface - what do you mean by configured correctly for DNS ?
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
Sorry Pete my mistake, I was thinking in pre-WiFi terms. DNS is managed in the router.
|
|
|
|
|
Try querying / refreshing the "arp cache".
arp | Microsoft Docs
And Ipconfig refreshes DHCP/DNS settings.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
modified 12-Jul-20 13:01pm.
|
|
|
|
|
The code below is for dicovering Logitech Media Servers running on my LAN
It works perfectly unless I have a server listening on the same pc ( Windows 10 ) as this code is running on.
It fails with "Only one usage of each socket address is normally allowed"
I have several of these servers running on my LAN and if I stop the one on my pc they are all found without error
int UDPPORT = 3483;
IPEndPoint ReceiveIP = new IPEndPoint(IPAddress.Broadcast,UDPPORT);
UdpClient ClientListener = new UdpClient(UDPPORT);
any ideas guys ?
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
modified 10-Jul-20 8:18am.
|
|
|
|
|
You cannot have multiple applications running on one system trying to listen on the same port.
|
|
|
|
|
Ok so that's why it works if the server is on a different box on the LAN
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
Exactly. A socket is like a telephone, it has a unique address (IP and port), and only one process can have the number at any one time. So if you have two processes on the same PC both listening on the same port, which one should be given the connection when a message arrives?
|
|
|
|
|
That's easy. You told the code to listen on a port that is already being used by another process.
Two processes cannot listen on the same port, be it another app entirely, or multiple instances of your app.
|
|
|
|
|
I see thanks
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
Or you use a "proxy"; one "port" listener that forwards to your other listening "subscribers", depending on content.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Console.WriteLine("-----Enter at least 10 numbers-----");
int[] num = new int[10];
int input = 0;
while (input <= 10)
{
Console.Write("Enter a whole number: ");
num[input] = Convert.ToInt32(Console.ReadLine());
input++;
}
Console.Write("\nThis are the list of Even Numbers: ");
int Even = 0;
while (Even < 10)
{
if (num[input] % 2 == 0)
Console.Write(num[input]);
Even++;
}
Console.Write("\nThis are the list of your Odd Numbers: ");
int Odd = 0;
while (Odd < 10)
{
if (num[input] % 2 == 1)
Console.Write(num[input]);
Odd++;
}
Console.ReadLine();
|
|
|
|
|
We can't tell - we have no access to your code while it is running, or to your data, and you need both in order to find out why this occurs, much less fix it.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
When you know where the problem is and what values you are using, you can start comparing that to the actual spreadsheet and work out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
while (input <= 10) means that input can be 10 inside the loop. In fact it will be, though that is not immediately obvious just from the loop condition. By the way, that is why for loops are normally preferred for counted loops - you can tell immediately what the range of the loop counter is.
num[input] happens, so num[10] had better exist.
.. but it does not, because num is only 10 elements long, not 11.
|
|
|
|
|
int[] num = new int[10]; int input = 0; while (input <= 10)
{
Your int array contains only 10 items but your while loop accepts an index value of 10 which is beyond the array limit.
Change the while loop to
while (input < 10)
|
|
|
|
|
You have to be careful with array indexers. Array indexes always start at 0, not 1.
When you declared an array with int[] num = new int[10]; , you created an array with 10 elements, numbered 0 through 9.
So, when you put the limit expression in your while (input <= 10) , you said the last index in the array was 10, not 9.
|
|
|
|
|
Hope you understand that Index start from 0 and not 1.
So if you have an array of 10 integers, the indices will be 0 ..9.
while (input <= 10)
{
num[input] = Convert.ToInt32(Console.ReadLine());
}
Here While loop will iterate 11 times when input = 0, 1, 2, ..10
when you try to access num[10], you will get an Index out of range .
|
|
|
|
|
I have mapper method which maps different types of property like bool,enum,string,int
But now I want to map my one of the custom class which is being inherited in several places
Back Story:
Earlier we were creating instance and assigning values in POM only, now we want to use Excel to pass value and map and then use in our methods
Object classes Which I want to map
namespace Framework.Model.PaymentOptions
{
public class PaymentOptions
{
public PaymentPortal portal;
public DeliveryMethod delivery = DeliveryMethod.Billing;
public PaymentOptions()
{
}
public PaymentOptions(Site site)
{
}
}
}
Which is inherited in below class
namespace Framework.Model.PaymentOptions
{
public class KlarnaOptions : PaymentOptions
{
public bool byCard = false;
public bool payLater = false;
public bool sliceIt = false;
public KlarnaOptions()
{
portal = PaymentPortal.Klarna;
}
}
}
Earlier we used to access and assign the values as below
Assigning Values
public class WorkflowParameters
{
public Site _site = default(Site);
public PaymentOptions paymentOptions = default(PaymentOptions);
}
var param = new WorkflowParameters()
{
paymentOptions = new KlarnaOptions()
{
delivery = DeliveryMethod.Billing,
payLater = true
}
};
Use in Methods would be as below
Checkout(param.paymentoptions);
Now we want to pass values from Excel Sheet
Mapper Method
public static class PropertyMapHelper
{
public static void Map(Type type, DataRow row, PropertyInfo prop, object entity)
{
List<string> columnNames = AttributeHelper.GetDataNames(type, prop.Name);
foreach (var columnName in columnNames)
{
if (!String.IsNullOrWhiteSpace(columnName) && row.Table.Columns.Contains(columnName))
{
var propertyValue = row[columnName];
if (propertyValue != DBNull.Value)
{
ParsePrimitive(prop, entity, row[columnName]);
break;
}
}
}
}
private static void ParsePrimitive(PropertyInfo prop, object entity, object value)
{
if (prop.PropertyType == typeof(string))
{
prop.SetValue(entity, value.ToString().Trim(), null);
}
else if (prop.PropertyType == typeof(bool) || prop.PropertyType == typeof(bool?))
{
if (value == null)
{
prop.SetValue(entity, null, null);
}
else
{
prop.SetValue(entity, ParseBoolean(value.ToString()), null);
}
}
else if (prop.PropertyType == typeof(long))
{
prop.SetValue(entity, long.Parse(value.ToString()), null);
}
else if (prop.PropertyType == typeof(int) || prop.PropertyType == typeof(int?))
{
if (value == null)
{
prop.SetValue(entity, null, null);
}
else
{
prop.SetValue(entity, int.Parse(value.ToString()), null);
}
}
else if (prop.PropertyType == typeof(decimal))
{
prop.SetValue(entity, decimal.Parse(value.ToString()), null);
}
else if (prop.PropertyType == typeof(double) || prop.PropertyType == typeof(double?))
{
double number;
bool isValid = double.TryParse(value.ToString(), out number);
if (isValid)
{
prop.SetValue(entity, double.Parse(value.ToString()), null);
}
}
else if (prop.PropertyType == typeof(DateTime) || prop.PropertyType == typeof(Nullable<DateTime>))
{
DateTime date;
bool isValid = DateTime.TryParse(value.ToString(), out date);
if (isValid)
{
prop.SetValue(entity, date, null);
}
else
{
isValid = DateTime.TryParseExact(value.ToString(), "MMddyyyy", new CultureInfo("en-US"), DateTimeStyles.AssumeLocal, out date);
if (isValid)
{
prop.SetValue(entity, date, null);
}
}
}
else if (prop.PropertyType.IsEnum)
{
var type = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
var enumValue = Enum.Parse(type, value.ToString(), true);
prop.SetValue(entity, enumValue, null);
}
else if (prop.PropertyType == typeof(Guid))
{
Guid guid;
bool isValid = Guid.TryParse(value.ToString(), out guid);
if (isValid)
{
prop.SetValue(entity, guid, null);
}
else
{
isValid = Guid.TryParseExact(value.ToString(), "B", out guid);
if (isValid)
{
prop.SetValue(entity, guid, null);
}
}
}
else if(prop.PropertyType == typeof(PaymentOptions))
{
}
}
public static bool ParseBoolean(object value)
{
if (value == null || value == DBNull.Value) return false;
switch (value.ToString().ToLowerInvariant())
{
case "1":
case "y":
case "yes":
case "true":
return true;
case "0":
case "n":
case "no":
case "false":
default:
return false;
}
}
}
Test Data Model
namespace Framework.Model.Excel
{
public partial class TestDataModel
{
public TestDataModel() {
}
[DataNames("TestName")]
public string TestName { get; set; }
[DataNames("paymentOptions")]
public PaymentOptions paymentOptions { get; set; }
[DataNames("SiteGroupId")]
public SiteGroup SiteGroupId { get; set; }
[DataNames("NickName")]
public string NickName { get; set; }
[DataNames("byCard")]
public bool byCard { get; set; }
[DataNames("payLater")]
public bool payLater { get; set; }
[DataNames("sliceIt")]
public bool sliceIt { get; set; }
[DataNames("portal")]
public PaymentPortal portal { get; set; }
[DataNames("delivery")]
public DeliveryMethod delivery{get;set;}
}
}
Currently, it is not mapping values of Payment Options, and also I do not know how will I access param.paymentoptions which will have delivery and payLater information
|
|
|
|
|
Before you start - do you have absolute control of the Excel format? If not you are in for a world of pain, you will need to locate the cell the values are in using interop or one of the excel libraries.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I am mapping excel values to test data model through mapper method, I am not using Interop
|
|
|
|
|
How are you getting the data from Excel?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Here is the function:
public static IList<TestDataModel> GetAllTestData(string keyName)
{
DataSet ds = new DataSet();
DataNamesMapper<TestDataModel> mapper = new DataNamesMapper<TestDataModel>();
DataTable dataTableALL = new DataTable();
List<TestDataModel> testData = new List<TestDataModel>();
using (var connection = new
OdbcConnection(TestDataFileConnection()))
{
connection.Open();
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = connection;
System.Data.DataTable dtSheet = null;
dtSheet = connection.GetSchema(OdbcMetaDataCollectionNames.Tables, null);
foreach (DataRow row in dtSheet.Rows)
{
string sheetName = row["TABLE_NAME"].ToString();
if (!sheetName.EndsWith("$"))
continue;
var query = string.Format("select * from [{0}] where TestName = '{1}'", sheetName, keyName);
cmd.CommandText = query;
DataTable dt = new DataTable();
dt.TableName = sheetName;
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
da.Fill(dt);
ds.Tables.Add(dt);
}
cmd = null;
connection.Close();
}
DataTable data= JoinExcelDatatoOneRow(ds);
testData = mapper.Map(data).ToList();
return testData.ToList();
}
|
|
|
|
|
So your data is coming in via ODBC which leaves you with a datatable. Make sure the source datatable has the same names as the destination object. Presumably excel does not have the payment options in the source so you need to load the default into the excel result set, simply return the default instead of the get/set property.
If Excel has the paymentoptions then it may be a complex type and will need specific processing to assign multiple values into your target object
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
So, if I browse to my site and login, I get a page with my personal images.
For example, I'm on-site with a client, take pictures, login and upload them. I want to retrieve them automatically from my laptop. To do so automatically, I need to login, get the HTML, grab the links then use WebClient.DownloadFile. Problem is, I can't see the HTML without a browser.
SO, more specifically - When I login with a browser and right click and "view HTML" I don't see the images in the markup, just the header and the footer HTML. The ONLY way to see the source is to use the inspector tool by right clicking on one of the images. So this code is generated by the browser, but not part of the original request.
I wrote a C# app that will log into my page and it works. I can login via SSL and my credentials, navigate pages BUT ... I can't see all the HTML.
I added a WebView2 form to my project (new Edge browser plugin for VS) and I can see the page, but I STILL can't get the source to get the path to the image.
So is there a way to get at this generated HTML programatically in C#? I can launch the dev tools (inspector) window with
myWebView2Browser.CoreWebView2.OpenDevToolsWindow(); ... but I need a way to view the ELEMENTS tab in that tool where the true HTML is.
I tried
myHTML = await myWebView2Browser.ExecuteScriptAsync("document.documentElement.outerHTML;"); ... and it gets the HTML, but NOT the FINAL rendered HTML that I can see in the inspector.
Hope this makes sense, it's making me crazy being so close! Thanks in advance!
|
|
|
|
|
Ask yourself - where are the images stored when I upload them?
They will either be in a database or the file system on the server. Instead of trying to use the HTML to get the file go directly to the source and download them from there, you should already have the credentials to access the server.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|