|
This is a somewhat wide subject, so the QnA was inappropriate.
I am working on some games and apps, and they need to talk to some MySQL servers and/or Azure resources, and so I need some connection strings. Usually I've made internal tools, where having the connection strings in code or in a XML or Json -file, was unproblematic.
Now I'm having the issue that APK's are basically Zip-files, and .net executables are de-compilable.
My first solution is to setup an intermediary web service to keep the connection strings unavailable from the app.
But I can't help but think that I'm missing something here.
Also, an extra middle-man webserver, increase the possible bottle-necks and failure points
What are this community's thoughts on the subject?
Thanks for your time!
|
|
|
|
|
Frank R. Haugen wrote: This is a somewhat wide subject, so the QnA was inappropriate. Actually quite the opposite. More people would see this in Q&A, rather than just those who look at C# questions (which this is not).
|
|
|
|
|
Frank R. Haugen wrote: Now I'm having the issue that APK's are basically Zip-files, and .net executables are de-compilable. Does not seem an issue for Rimworld.
Frank R. Haugen wrote: What are this community's thoughts on the subject? If you can't afford the user in the database, don't give away the connectionstring. Simple as that. Third parties can't keep secrets on a computer that isn't theirs.
Who is going to be the "owner" of the data? You, or the user? Is the user going to be allowed to make changes? If no, simply give them a connection-string that's hooked to a user with limited (read) access.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello there. I want to do an ftp server-client program with c #. I created free hostting for this, but this hostting does not give me ftp authorization, can you help me with this.
|
|
|
|
|
We can't add FTP authorization for you - you need to talk to your hosting service and see what they can do for you. It may be that your free plan does not include any FTP access and may well be blocked by their firewall (free plans are generally limited in some ways, and I don't bother with them at all any more as they have all been more hassle than they were worth) but that is something you will have to discuss with your provider.
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!
|
|
|
|
|
Free hosting companies make their money by showing ads on the sites that you host there. Abusing their service to provide drive-functionality in the cloud would be probably in violation of their terms of use.
..but that's why they block FTP. It's a question that comes by a few times a year. If you want FTP, you will probably have to pay for the service.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
double a;
double da, fn, dfn_da;
da = 0.00;
double epsilon = 1.0e-10;
bool converged = true;
a = 10;
int n = 0;
do
{
for (int Ls = 10; Ls <= 30; Ls += 5)
{
for (double H = 0.5; H <= 2.5; H += 0.5)
{
n++;
fn = a * Math.Cosh(Ls / (2 * a)) - a - H;
dfn_da = -(Ls * Math.Sinh(Ls / (2 * a)) / (2 * a)) + Math.Cosh(Ls / (2 * a)) - H;
if (Math.Abs(dfn_da) < epsilon)
{
converged = false;
break;
}
else if (n == 200)
{
converged = false;
break;
}
da = -fn / dfn_da;
a += da;
}
while (Math.Abs(da) > epsilon)
{
if (converged)
Console.WriteLine("The root of the equation is: {0}", a);
}
}
}
}
}
|
|
|
|
|
What issue, all you have done is dump some code into the forum. Tell us what the problem is and where it occurs and you may get a better result.
Check the positioning of your do-while loop.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
The indentation shows you what the problem is!
Not only are you missing a close curly bracket, but your while is part of your outer for loop, rather than the do ...
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!
|
|
|
|
|
Hi. There are 3 lists: List1, List2, List3;
List1: 1,2,3,... (can be empty)
List2: A,B,C,D,E,... (can be empty)
List3: a,b,c,... (can be empty)
I need to parse it into one List<obj> where OBJ{ data_list1, data_list2, data_list3}:
(1) 1,A,a
(2) 1,A,b
(3) 1,A,c
..
(..) 3,E,c
...
All variants of existing data form lists.
The list can be empty, and I need to use empty like a data. For example:
(1) empty, A,a
...
(2) empty,E,c
Could you advise the solution, please?
|
|
|
|
|
There is a Zip function which does some of what you want: Enumerable.Zip(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst,TSecond,TResult>) Method (System.Linq) | Microsoft Docs[^]
List<int> list1 = new List<int>() { 1, 2, 3 };
List<string> list2 = new List<string>() { "A", "B", "C"};
List<string> list3 = new List<string>() { "a", "b", "c" };
var x = list1.Zip(list2, (a, b) => new { a, b }).Zip(list3, (a, c) => new { a.a, a.b, c }).ToList();
But ... the problem is that your lists are not necessarily the same length. I think that to get this to work in any practical way, you'd have to "pad" all three lists with NULL entries in order to use any standard methods. You would probably be better off writing your own class and providing a constructor that takes three lists and combines them the way you want.
What are you trying to do that you think this is a good idea? There may be better ways.
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!
|
|
|
|
|
This appears to me to require generating permutations/combinations. There are some excellent resources here for this in C#: I suggest you start here: [^].
And: [^] Here's a recent article that looks interesting: [^]
As OriginalGriff suggests, you need to get your data "normalized."
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
|
Since you've got a fixed number of lists, this should be fairly easy to do with a combination of SelectMany[^] and DefaultIfEmpty[^]:
var result = list1.DefaultIfEmpty().SelectMany(l1 => list2.DefaultIfEmpty().SelectMany(l2 => list3.DefaultIfEmpty().Select(l3 => new { l1, l2, l3 }))).ToList();
It's slightly cleaner using the query syntax:
var query = from l1 in list1.DefaultIfEmpty()
from l2 in list2.DefaultIfEmpty()
from l3 in list3.DefaultIfEmpty()
select new { l1, l2, l3 };
var result = query.ToList();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have create a Win form app and create Polygons as follows:
private List<list<pointf>> Polygons = new List<list<pointf>>();
I store this polygons with Xml.Serialization, into a MySQL database as string and Deserialize it with my console app into a list of polygons again.
In my console app, which eventually is going to run from Raspberry Pi, I'm getting data from USB, which consist of floating X and floating Y coordinates.
Now I want to know how do I check if this point is within one of the polygons. I've tried it first with WinForms app and it works great.
public static bool IsPointInPolygon(IList<pointf> polygon, PointF testPoint)
{
try
{
bool result = false;
int j = polygon.Count() - 1;
for (int i = 0; i < polygon.Count(); i++)
{
if (polygon[i].Y < testPoint.Y && polygon[j].Y >= testPoint.Y || polygon[j].Y < testPoint.Y && polygon[i].Y >= testPoint.Y)
{
if (polygon[i].X + (testPoint.Y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) * (polygon[j].X - polygon[i].X) < testPoint.X)
{
result = !result;
}
}
j = i;
}
return result;
}
catch (Exception ex)
{
MessageBox.Show("error - " + ex.ToString());
return false;
}
I don't want to draw something, I know it's a console app, just getting a bool or int value back from the Test.
Any suggestions or help please?
|
|
|
|
|
What exactly is the problem? If the calculations work in a Windows Form app, then they will work in any other app.
|
|
|
|
|
I didn't add the drawing reference. Not my day. Thank you Richard. It works
modified 12-Nov-18 8:28am.
|
|
|
|
|
But the calculation is the same. Create a set of points which describe the polygon. Now do the comparisons with your test points.
|
|
|
|
|
Says who?
Of course you can! See the code I gave you in my reply - that code works just fine in a Console app!
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!
|
|
|
|
|
If you create a GraphicsPath object for the points, you can use that to check:
System.Drawing.Drawing2D.GraphicsPath poly = new System.Drawing.Drawing2D.GraphicsPath();
poly.AddLine(10, 10, 90, 10);
poly.AddLine(90, 10, 90, 90);
poly.AddLine(90, 90, 10, 90);
poly.AddLine(10, 90, 10, 10);
Point inPoly = new Point(50, 50);
Point outPoly = new Point(0, 0);
Console.WriteLine(poly.IsVisible(inPoly) ? "IN" : "OUT");
Console.WriteLine(poly.IsVisible(outPoly) ? "IN" : "OUT");
The beauty of that is that the poly can be extremely complex and the framework will sort it out. For example, an hourglass:
System.Drawing.Drawing2D.GraphicsPath poly = new System.Drawing.Drawing2D.GraphicsPath();
poly.AddLine(10, 10, 90, 90);
poly.AddLine(90, 90, 10, 90);
poly.AddLine(10, 90, 90, 10);
poly.AddLine(90, 10, 10, 10);
Point inPoly = new Point(50, 40);
Point outPoly = new Point(40, 50);
Console.WriteLine(poly.IsVisible(inPoly) ? "IN" : "OUT");
Console.WriteLine(poly.IsVisible(outPoly) ? "IN" : "OUT");
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!
|
|
|
|
|
How to get the WIFI and LAN usage in C#.
Also my requirement is to get the usage between specified date range.
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So stop trying to type as little as possible and explain what it is you are trying to do, what you have tired, where you are stuck, and what help you need!
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 Griff,
Actually I am new to this implementation. Just want to know any API, till now I haven't got any API.
|
|
|
|
|
API for what? You haven't told us what you want!
We can't see your screen, we can't access your HDD, we can't read your mind.
We really do only get exactly what you type ... no other context.
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!
|
|
|
|
|
namespace ConsoleApplication2
{
using System;
using System.Diagnostics;
using System.Net.NetworkInformation;
using System.Threading;
class MainClass
{
static void Main()
{
NetworkInterface nic = NetworkInterface.GetAllNetworkInterfaces()[0];
IPv4InterfaceStatistics ip4 = nic.GetIPv4Statistics();
IPInterfaceStatistics ip = nic.GetIPStatistics();
long ip4data = ip4.BytesReceived + ip4.BytesSent;
long ipData = ip.BytesReceived + ip.BytesSent;
Console.WriteLine(ip4data + ipData);
NetworkInterface[] interfaces
= NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in interfaces)
{
if (ni.Name == "Ethernet")
{
Console.WriteLine("LAN Usage:");
Console.WriteLine(" Bytes Sent: {0}",
ni.GetIPv4Statistics().BytesSent);
Console.WriteLine(" Bytes Received: {0}",
ni.GetIPv4Statistics().BytesReceived);
}
else if (ni.Name.ToLower() == "wi-fi")
{
Console.WriteLine("WIFI Usage:");
Console.WriteLine(" Bytes Sent: {0}",
ni.GetIPStatistics().BytesSent);
Console.WriteLine(" Bytes Received: {0}",
ni.GetIPStatistics().BytesReceived);
}
}
}
}
}
Now can you answer?
This code is working for current system session, how do I modify to read after all the reboot session usage?
Something like below:
Windows 10 : Go to Settings -> Network & Internet -> Data Usage
You can see the 1 month data usage.
|
|
|
|
|