Click here to Skip to main content
15,066,928 members

Comments by Henry Hunt (Top 48 by date)

Henry Hunt 1-Jan-14 12:54pm View
   
I have looked online for ages but can't find anything that works. Most say that you should make sure this is in both the client and server applications:
bindings

[nettcpbinding]
[binding name="NetTcpBinding_IService1"]
[security mode="None"/]
[/binding]
[/nettcpbinding]
...but I don't know where to put it in my host. I have tried and put it directly in the system.servicemodel section but I then get a CommunicationException so I don't know what to do.
Henry Hunt 1-Jan-14 10:11am View
   
Finally some help!! Yes...but I don't understand what you mean. Is it not able to log onto the host at the server?
Henry Hunt 1-Jan-14 9:45am View
   
Oh my god! I completely missed it ahaha. Thank you for that! It works perfectly now.
Henry Hunt 30-Dec-13 13:17pm View
   
Isn't there any way I can avoid using another thread? All I want to do is change the visibility of a control and wait for it to render before continuing, is it really that hard?!
Henry Hunt 29-Dec-13 14:33pm View
   
Reading this, am I right in thinking that http is not the right 'thing' to be using because it is not hosted on a website or intranet or online? Should I be using the netTcpBinding instead so I use 'net.tcp://' instead of 'http://'? Maybe that it why it is not working, because it thinks its a service or file on a website not an endpoint?
Henry Hunt 29-Dec-13 12:15pm View
   
I have not posted any code for the service, only the host console that uses it. This is the code for the client which is also a console:

static void Main(string[] args)
{
CalculatorClient client = new CalculatorClient();

Console.WriteLine(client.Endpoint.Address);
Console.WriteLine(client.State);
Console.WriteLine(client.Endpoint.Name);
Console.WriteLine(client.Endpoint.ListenUri);


Console.WriteLine(client.Login("password"));
Console.WriteLine(client.Login("hello"));

double value1 = 100.00D;
double value2 = 15.99D;
double result = client.Add(value1, value2);
Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

value1 = 145.00D;
value2 = 76.54D;
result = client.Subtract(value1, value2);
Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

value1 = 9.00D;
value2 = 81.25D;
result = client.Multiply(value1, value2);
Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

value1 = 22.00D;
value2 = 7.00D;
result = client.Divide(value1, value2);
Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);

client.Close();
Console.ReadKey();
}


Right, all I basically want is to have a computer. This computer will be downloading data from the internet and saving it (that part has nothing to do with WCF) and it will also run the server software. There will be lots of people on separate computers with a piece of software that will use the service to send a code back to the server. The server will then read that code and select the relevant piece of data (which it downloaded previously) to send back to the client (whether it be an image file or just a value). It is simple and I have it working absolutely perfectly with the client and server on the same machine, it sends the data back just like I want but the error occurs whenever I try to run the client on another machine from the server and I assumed it is a problem with how I have configured both the server and client.
Henry Hunt 28-Dec-13 11:55am View
   
That is the bit I can never do with any success! How would I change this endpoint address to make it work on another machine: http://localhost:8000/SystemControllers/Administrator

Do I just have to change 'localhost:8000' to the IP address of the machine that is running the client? I don't understand this part.
Henry Hunt 28-Dec-13 9:36am View
   
Oh, so all I have to do is change the endpoint URLs so that they are not localhosts and make sure all clients use the same URL as the host?
Henry Hunt 20-Dec-13 10:48am View
   
Great, worked perfectly! Thank you.
Henry Hunt 16-Dec-13 11:02am View
   
Ah I get you, yes it may be useful. All I really want is a list of URLs to all of the pages belonging to a website/server/domain
Henry Hunt 16-Dec-13 11:00am View
   
Deleted
Ah I get you, yes it may be useful. All I really want is a list of URLs to all of the pages belonging to a website/server/domain
Henry Hunt 16-Dec-13 10:57am View
   
Sorry, what do you mean by that?
Henry Hunt 30-Nov-13 7:26am View
   
I've got it, it works now. I had to do DataContext = this and a few other things when updating the listview so there are now no references to the listview control itself. Thank you!
Henry Hunt 30-Nov-13 5:01am View
   
Does the XAML affect how the list reloads? Because I am still getting a NullReferenceException. I have pasted your C# code as it is without changing anything and am using this to control the items in it:

timeSteps.ItemsSource = null;
TimeStepDataCollection.Clear();

XmlDocument capabilities = new XmlDocument();
List<timestep> timesteps = new List<timestep>();
List<string> timeList = new List<string>();
List<timestep> reloading = new List<timestep>();

capabilities.Load(Data.MetOffice.DownloadXml(
"http://datapoint.metoffice.gov.uk/public/data/layer/wxobs/all/xml/capabilities?key=" +
UserProfile.Read.ApiKey(), DateTime.Now.Second.ToString()));

for (int x = 0; x < capabilities.SelectNodes("//Layer[@displayName='Rainfall']/Service/Times/Time").Count; x++)
{
timeList.Add(capabilities.SelectNodes("//Layer[@displayName='Rainfall']/Service/Times/Time")[x].InnerText);
}

foreach (string s in timeList)
{
TimeStepDataCollection.Add(new TimeStepData() {
TimeStepItem1 = (DateTime.Parse(s.Remove(10).Replace("-", "/")).ToString("dd/MM/yyyy") +
" at " + s.Remove(0, 11).Remove(5)) + ":00", TimeStepItem2 = s });
}
new Global().UpdateDataTree(set: "Observation Maps", entry: "Rainfall Rate",
step: timeList.ToArray(), type: "Observation", freq: "15 Minutes", dist:
"Met Office", serv: "OBSERVATION", unit: "mm/h (millimetres per hour)", key: "true");

timeSteps.ItemsSource = TimeStepDataCollection;

Maybe I am doing it wrong?
Henry Hunt 30-Nov-13 4:48am View
   
Deleted
Thank you so much!! That has helped me finish quite a few parts of my application. :)
Henry Hunt 29-Nov-13 14:54pm View
   
How would I implement the observable collection? I have looked on the internet for observable collections and listviews but cannot get anything to work
Henry Hunt 15-Nov-13 16:00pm View
   
This works, thank you but where would I write my main code to do things like actually download the data? I'm a bit confused as to which classes do what
Henry Hunt 15-Nov-13 15:43pm View
   
THAT'S IT!! That's what I want, like a list<>
Henry Hunt 12-Nov-13 3:00am View
   
Ahhh I get it now... So I should just change the event args in the method to something like MouseEventArgs and add it as a handler to the ListView?
Henry Hunt 11-Nov-13 13:43pm View
   
But that's the problem...I don't know how to use the method from that post: I mean you can't exactly go statusLabel.Content = new GlobalClasses().UpdateStatus(*** This is the bit I don't get. what do I do with this bit: DragEventArgs?***) or can you? That is what I want to know. I have never come across 'functions' with events in them apart from the obvious event handlers for controls but I wouldn't class that as a 'function' that I have written.
Henry Hunt 11-Nov-13 12:55pm View
   
OK...I have found this code below:
private ListViewItem FindListViewItem(DragEventArgs e)
{
var visualHitTest = VisualTreeHelper.HitTest(dataTree, e.GetPosition(dataTree)).VisualHit;
ListViewItem listViewItem = null;
while (visualHitTest != null)
{
if (visualHitTest is ListViewItem)
{
listViewItem = visualHitTest as ListViewItem;
break;
}
else if (visualHitTest == dataTree)
{
MessageBox.Show("Found ListView instance");
return null;
}
visualHitTest = VisualTreeHelper.GetParent(visualHitTest);
}
return listViewItem;
}
...but I don't know how to use/call it because of the event in the parameters. Do I haver to attach it to an event in my ListView to use it or what? It was from here: http://stackoverflow.com/questions/12977046/finding-out-which-item-the-mouse-is-over-in-a-list-view-while-using-itemssource
Henry Hunt 9-Nov-13 12:28pm View
   
But it doesn't work like that for a ListView item. Don't you have to determine the current pointer location and then get the item under it or something? That is the part I cannot do.
Henry Hunt 5-Nov-13 14:04pm View
   
Ok thank you, I will have another go at writing it...one thing though: would this be a DateTime or an int?: nextExpected = time() + updateRate, and is time() just the current time?
Henry Hunt 25-Oct-13 14:25pm View
   
As you said this code does work but it limits me to what I can do as I cannot use this code with the 'System.Windows' and 'System.Drawing' namespaces both referenced as I get the ambiguity error between the point definition, that was why I needed a 'conversion'
Henry Hunt 23-Oct-13 15:05pm View
   
Yes, from a url and save it to the disk
Henry Hunt 21-Oct-13 13:46pm View
   
Perfect! Thank you
Henry Hunt 19-Oct-13 5:15am View
   
Thank you, I have accepted it. Just out of interest, would you say that WCF is the right way to go to match login details with a database on another computer when someone logs in or is there a better way?
Henry Hunt 18-Oct-13 12:55pm View
   
ah ok...What I am trying to do is when someone signs in or fills in details to request an account it encrypts the entered data and sends it using WCF to another computer containing a database of accounts which it then decrypts the sent data and cross matches it with the database to get a correct login and then sends a message back saying it can log in. Just to make sure you know what context I want to use the encryption in. Another thing: I am amazed at how much knowledge you have about not just C# but lots of other languages and computers and encryption and a lot about everything to do with computer programming. Where and how have you got it all from?!
Henry Hunt 18-Oct-13 12:23pm View
   
By huge I mean hundreds or thousands of characters and the purpose is that the number is a sequence of characters from encryption I have made where it converts inputted characters to their ascii codes and does some other stuff with it to make it 'secure'. I know it sounds like a crazy idea and that it could be cracked maybe quite easily but still...
Henry Hunt 18-Oct-13 12:22pm View
   
Deleted
By huge I mean hundreds or thousands of characters and the purpose is that the number is an encryption I have made where it converts inputted characters to their ascii codes and does some other stuff with it to make it 'secure'.
Henry Hunt 18-Oct-13 12:19pm View
   
Thank you I will have a go at that. It is annoying because I don't actually need the number to do any maths on, I only need it to stand in as a very, very long sequence of numbers.
Henry Hunt 16-Oct-13 3:00am View
   
In both errors, it is when I load the XmlDocument capabilities with either a local file or a file on the web. So it is when I request it I suppose.

Loading a file from the web: Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Loading a local file: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Henry Hunt 16-Oct-13 2:44am View
   
Nope same error when I save it to the disk and use that instead. Is it something to do with the security rights of the application or code? But this time it is a request for a FileIOPermission not a web one I just noticed.
Henry Hunt 4-Oct-13 14:43pm View
   
Thank you for this, it helped but the code with the error is always in the automatically generated code by the designer to store all of the properties for the controls I have on the form and not code that I have written so I really don't know how to solve it.
Henry Hunt 4-Oct-13 11:01am View
   
Yes, completely fine. Then I saved and closed and turned off my computer. Had my day and come back to find it starts to throw errors
Henry Hunt 4-Oct-13 10:54am View
   
- I can't see any memory usage problems and I don't have much open

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.5.50709 SP1Rel
Installed Version: C# Express
- Windows 8 64bit
Henry Hunt 8-Sep-13 12:08pm View
   
Hello again, I have just one more thing for you. How would I reference to a specific 'set' of elements depending on on of the containing element values instead of the attribute at the top of the 'set' of elements. For example: The code I want to read is below. How would I get the Risk level from specifying the Area element?

How would I get the risk level for the Area value of East Highland? I don't want to use indexing, ie: using SelectNodes("")[n].innerText as the 'sets' of MountainForecast elements could be in a different order Thank you.


mountainforecastlist
mountainforecast
datadate/2013-09-08T04:04:39Z/datadate
validfrom/2013-09-08T04:00:00Z/validfrom
validto/2013-09-12T04:00:00Z/validto
createddate/2013-09-08T03:05:48Z/createddate
uri/http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/mountainarea/{format}/100?key={key}/uri
Area/Brecon Beacons/Area
risk/Medium/risk
mountainforecast
mountainforecast
datadate/2013-09-08T03:26:42Z/datadate
validfrom/2013-09-08T03:00:00Z/validfrom
validto/2013-09-12T03:00:00Z/validto
createddate/2013-09-08T02:26:48Z/createddate
uri/http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/mountainarea/{format}/101?key={key}/uri
Area/East Highland/Area
risk/Medium/risk
mountainforecast
mountainforecastlist

Had to remove the tag start and ends so hope you can read it, I put / between element and its value.
Henry Hunt 6-Sep-13 15:09pm View
   
Thank you, that worked.
Henry Hunt 6-Sep-13 14:46pm View
   
Thank you...I now have this code but there is a problem:

int minutes = Convert.ToInt16(DateTime.Parse("2013-09-05T14:00:00").ToString("mm"));
int hours = Convert.ToInt16(DateTime.Parse("2013-09-05T14:00:00").ToString("HH"));

TimeSpan mySpan = new TimeSpan(minutes, hours, 0);

int totalSecondsSinceMidnight = Convert.ToInt32(mySpan.TotalMinutes);
MessageBox.Show(totalSecondsSinceMidnight.ToString());

It returns 14 and there surely aren't 14 minutes since midnight are there? Could you work out why this is? Thank you.
Henry Hunt 6-Sep-13 12:01pm View
   
Does this work with attributes in the same way?
Henry Hunt 4-Sep-13 14:08pm View
   
But surely if I have 24 individual labels and I want each one to contain a different value from a different attribute from the same document and I don't want to use any type of list controls then that is how to do it? I can't think of any other way to populate different labels with different values other than one by one.
Henry Hunt 29-Aug-13 13:23pm View
   
I think I jump to asking for help after not trying for long enough myself! Solved it myself with this code:

static void Main(string[] args)
{
XmlDocument SiteList = new XmlDocument();
SiteList.Load("C:/Users/Henry/WeatherWatcher/Development/sitelist.xml");
List<string> FinalList = new List<string>();
for (int x = 0; x < SiteList.SelectNodes("/Locations/Location/@id").Count; x++)
{
for (x = 0; x < SiteList.SelectNodes("/Locations/Location/@latitude").Count; x++)
{
for (x = 0; x < SiteList.SelectNodes("/Locations/Location/@longitude").Count; x++)
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("ID: " + SiteList.SelectNodes("Locations/Location/@id")[x].InnerText);
Console.WriteLine("LA: " + SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText);
Console.WriteLine("LO: " + SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText);
Console.WriteLine("HF: " + Haversine.Formula(Convert.ToDouble(Properties.Settings.Default.LATITUDE), Convert.ToDouble(Properties.Settings.Default.LONGITUDE), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText)));
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("AL: " + Haversine.Formula(Convert.ToDouble(Properties.Settings.Default.LATITUDE), Convert.ToDouble(Properties.Settings.Default.LONGITUDE), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText)) + "---" + SiteList.SelectNodes("/Locations/Location/@id")[x].InnerText);
FinalList.Add(Convert.ToString(Haversine.Formula(Convert.ToDouble(Properties.Settings.Default.LATITUDE), Convert.ToDouble(Properties.Settings.Default.LONGITUDE), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText)) + "---" + SiteList.SelectNodes("/Locations/Location/@id")[x].InnerText));
Console.WriteLine(Environment.NewLine);
}
}
}
foreach (object o in FinalList)
{
Console.WriteLine(o);
}
Console.ReadKey();
}
Henry Hunt 29-Aug-13 11:49am View
   
Doesn't work because the y loop follows on from the x loop. After getting the longs using x it then gets the lats with y using x to tell it to count up the same amount as it did to get the longs if that makes any sense.
Henry Hunt 19-Aug-13 5:22am View
   
I have just solved it myself with

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (Properties.Settings.Default.FirstRun == true)
{
APIKey APIKey = new APIKey();
Application.Run(APIKey);
}
else
{
MAIN_WeatherWatcher MAIN_WeatherWatcher = new MAIN_WeatherWatcher();
Application.Run(MAIN_WeatherWatcher);
}
Henry Hunt 18-Aug-13 19:01pm View
   
I've tried doing 'Application.Run()' and then doing an if statement to check of the setting is true or false and telling it to show the first form if it is true and the second if it is false but that didn't work.
Henry Hunt 18-Aug-13 18:52pm View
   
Oh I mean open or show it
Henry Hunt 7-Aug-13 6:53am View
   
Another thing, how would I read an attribute and put it into a string for use in a URL? For example, how would I read the attribute value for 'displayName' in the SatelliteVis layer and store it in a string? Thanks.
Henry Hunt 6-Aug-13 12:44pm View
   
Thank you so much, it worked great after a few changes. One more thing, it returns the whole element (e.g: 'time 2013-08-06T15:00:00 /time' is there a way to just get the data inside the tags or would I just use replace to replace the 2 tags either side of the data with an empty space?