|
You probably can't detect the change unless you poll for the IP address. Your "home network" is probably on the wrong side of the cable modem to get any kind of hint of what's going on.
The traffic to change the modem IP isn't routed to the inside of the network and you can't really get the IP address without going to an external site and having it tell you the IP address the request was sent from, which will NOT be your machine IP, but your cable modems IP.
|
|
|
|
|
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You can only tell by asking the outside world what the IP is - the internet IP is not transferred into the LAN with "normal" messages.
Have a look here: Using IP based Geolocation - and why it's pretty much useless.[^] It includes an app I knocked up to find out my IP so I could tell when it changed. You'd need to modify it to run in a thread in your app, but that's not too complicated.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I am new to API and MVC. I have a MVC application which calls a third party Api. The Api returns the data in Json format.
I want to get the Json data and map it to a class object.
modified 28-Aug-18 10:02am.
|
|
|
|
|
|
Hi there,
I'm trying to make a program which sends a command and getting certain values from the result from an invisble command line program which has the current values.
Here's a HelloWorld-esque example:
How can I get this working? (e.g putting only that number 5 next to the amount)
~wesley9946
|
|
|
|
|
Wesley there is a problem with your question - this is your first post and you want us to click on a link that is not recognised. And you are looking for "invisible" code, immediately raises the level of paranoia in most of us.
Post your code rather than a link.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
With "invisible", I mean that there's a hidden cmd running in the background, somehow I couldn't get the image in the post so that's why I made a link to it.
So.... the problem here is that i don't know the piece of code that makes the winform read and filter the info from that hidden cmd so maybe you can help me with that.
|
|
|
|
|
You have to realise that we can't see your screen, can't access your HDD, and can't read your mind - we only get exactly what you type to work with. While there are ways to run a command from a C# program without a window attached and to retrieve the output from it, we don't know what - exactly - you are doing at the moment, or how you do it.
So show us the code that kicks off the command - copy'n'paste of the relevant fragments are good - and explain what you mean by "hidden cmd" - because there are a a number of things that could be as well - a windowless CMD prompt, a windows service (which has no UI, and can never have one), ... We don't know and we can't see!
And we can't tell you what code you need to use unless we understand what your problem is in the first place, so help us to help you!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
I've got a really weird problem here !
I've written a C# console app to get data from predefined IP addresses, after the calculations, I want the data to be inserted to a MySQL database so I can read it and do more calculations if needed using a PHP web application,
on my lap top everything is working perfectly,
when I run the C# app on the server, the data is being handled perfectly until the last step which is inserting it, but when it inserts the data, it's like an integer, no decimals.
I used VS Studio tools and tracked my variables, they are correct even in the sql statements but on the database they're losing their decimals.
I'm using windows 10 on my laptop and the server has windows Server 2016
here's the C# code :
<pre lang="c#">
public static string send_to_db(int uid, float prs, float btlvl, float f1, float f2, double t1, double t2, int dState, int supState, string datetime, string stmt)
{
MySqlConnection connection = null;
string feedback = "";
double min_prs_val = 0, max_prs_val = 0;
btlvl = (btlvl * 100) / 12;
try
{
connection = new MySqlConnection(stmt);
connection.Open();
MySqlCommand insertData = new MySqlCommand($"INSERT INTO pm_data_records (pm_detail_id, pm_pressure, pm_battery_charge, pm_flow1, pm_flow2, pm_tot1, pm_tot2, pm_door, pm_sup, pm_sent_time) VALUES('{uid}','{prs}','{btlvl}','{f1}','{f2}','{t1}','{t2}','{dState}','{supState}','{datetime}')", connection);
insertData.ExecuteNonQuery();
MySqlCommand updateData = new MySqlCommand($"UPDATE pm_data_last SET pm_detail_id = '{uid}', pm_pressure = '{prs}', pm_battery_charge = '{btlvl}', pm_flow1 = '{f1}', pm_flow2 = '{f2}', pm_tot1 = '{t1}', pm_tot2 = '{t2}', pm_door = '{dState}', pm_sup = '{supState}', pm_sent_time = '{datetime}' WHERE pm_detail_id = '{uid}'", connection);
updateData.ExecuteNonQuery();
...
I installed visual studio on the server and copied the code from my laptop and compiled it there too (after installing the MySQL for vs files) and still no decimals,
I'm outta ideas, help me plz ! tnx
|
|
|
|
|
How do you find out that the values are being changed? What is the structure of the table where you add these values?
I notice you are using inline formatting on your INSERT statements. You should print out the final statement to see exactly what is being passed to the database.
modified 26-Aug-18 9:42am.
|
|
|
|
|
To add to what Richard has said, don't do it like that!
Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.
When you concatenate strings, you cause problems because SQL receives commands like:
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood' The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable; Which SQL sees as three separate commands:
SELECT * FROM MyTable WHERE StreetAddress = 'x'; A perfectly valid SELECT
DROP TABLE MyTable; A perfectly valid "delete the table" command
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.
So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You left out a critical piece of information - the data type of the database columns where the floats are stored!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
RTFM=> 5.7.1 Preparing Statements in Connector/NET
As I am not a MySql developer- so I checked first on your INSERT statement as all of your values are wrapped in quotes, and to see how to use parameters. Wouldn't you know it, them resources at MySQL had a document with both in the same article
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
RTFM is not welcome on this site.
If it bothers you too much to answer the question, then simply ignore it and move on.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I have excel file which has data like below table. Where "Reviewer", "Comments" these are cell header with having some data. so my requirement is to insert new data in the same excel file in next empty line under the respective header.
Reviewer | Comments | Comment Type |Comment Date
---------------------------------------------------------------
rajdra1 1 | Read loud | Sticky Note | 08/09/2018
rajdra1 1 | MSTP | Highlight | 08/09/2018
rajdra1 2 | Readout | Underline | 08/09/2018
rajdra1 2 | A few | Inserted Text | 08/09/2018
rajdra1 2 | Not required | Highlight | 08/09/2018
So how to read all cell as per header name update data under specific header c#
suppose my new data is -
Reviewer - "ABC"
Comments - "myComment"
Comment Type - "Highlight"
Comment Date - "09/09/2018"
expected output -
Reviewer | Comments | Comment Type |Comment Date
---------------------------------------------------------------
rajdra1 1 | Read loud | Sticky Note | 08/09/2018
rajdra1 1 | MSTP | Highlight | 08/09/2018
rajdra1 2 | Readout | Underline | 08/09/2018
rajdra1 2 | A few | Inserted Text | 08/09/2018
rajdra1 2 | Not required | Highlight | 08/09/2018
ABC | myComment | Highlight | 09/09/2018
|
|
|
|
|
If i have a list of tasks, and I fire them off using Task.WhenAll(). What order are they fired off in?
I can't seem to find anything about this. When It try it in test console app the order is always the same - they fire in the order they're listed in the array.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
As always, the answer is "it depends".
It will depend on the current TaskScheduler[^], which is the class that actually schedules the work.
The default TaskScheduler uses the thread pool, so it will also depend on what other things are happening in your AppDomain at the time.
But in general, you can't depend on the tasks executing in a defined order. If your code requires a specific order, then that's a bug. You need to rewrite your code to explicitly execute the tasks in the required order, or to use synchronization primitives to prevent one task from executing before a task it depends on has finished.
One simple solution would be:
await Task.WhenAll(
FirstTask(),
SecondTask(),
ThirdTask(),
);
await FourthTask();
await Task.WhenAll(
FifthTask(),
SixthTask(),
);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I figured that was the case.
My problem is that I have 2 classes, one long running and on short running. So I'm passing a ManualResetEvent into both so that the shorter one pauses until the longer is done.
I just wanted to be sure the Longer one starts first. Probably not a big deal but I was hoping
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
A better solution is a Parallel.ForEach, followed by a WaitAll - there is no need to pause the faster task. Just wait for both tasks having finished.
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
Hello all
i know how can i unzip file from hardisk
but how can i Unzip file from resources directly without copy it to outside of resources first
|
|
|
|
|
Please don't repost if your question does not appear immediately: all of these went to moderation and required a human being to review them for publication. In order to prevent you being kicked off as a spammer, all four had to be accepted, and then I have to clean up the spares. Have a little patience, please!
I'll delete the other three versions.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Most compression libraries treat the file to be decompressed as a stream of bytes. If you have the source code for the library, you can modify it as follows:
- Load the resource (instead of opening the file)
- Convert all reads from the file to memcpy() operations
- Discard the resource (instead of closing the file)
In a well-written library, you shouldn't have too many places that require modification.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|