|
What have you tried?
Where are you stuck?
What help do you need?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I really don't know where to start. I don't know what things are used for this purpose. I know a TCP client is used for similar things in C#.
|
|
|
|
|
Is the "remote" MYSQL db on the same device as the "remote" Windows desktop app?
If it is, have the Windows app retrieve the (time stamped) data it needs.
Even if it isn't, since you know how to send to a remote MySQL db, I assume you should be able to read / poll it remotely also.
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
|
|
|
|
|
Hello Friends,
I have a requirement and would like to know how to code for this in C#.net:
I receive two files, one in BAI2 format and one in AMI format.
1.) How do I take AMI formatted file and convert it into BAI2 format file?
2.) How to do edit BAI2 file to add a unique identifier at the end of each line in the file.
I have installed Visual studio 2019.
TIA.
Sasi
|
|
|
|
|
There is no shortcut: you will need to learn to read AMI format: Amazon Machine Image - Wikipedia[^] and BA12 format: BAI2 Format Specification - SEPA for Corporates[^] and then write a reader for one, and a writer for the other. Then you need to work out what parts of your AMI document you need to access and store as BA12, because from what I can see the two are completely unrelated ...
Good luck with that: AMI format does not look like fun to process at all!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I had a class ClusterHazardLocations which inherited some levels down from IEnumerable<IHazardLocation> . In case of an alarm, an AlarmInfo object is transferred from a sensor device via WCF to some other computer showing the information to the user. That AlarmInfo has an IHazardLocations property, and in this case it was a ClusterHazardLocations object. It used to work.
Then I added a simple function to that ClusterHazardLocations class: public void Add(IHazardLocation other) . The mere existence of the function - even with an empty body - causes the WCF communication to fail. I do not understand that at all. After all, IEnumerable does not have an Add method and the class does not derive from a List or similar base class.
After renaming the Add method to AddHazardLocation , everything worked again.
Could you please explain how this odd behavior of WCF was caused?
Edit:
"a small project" with WCF... Ehm. But a small interface /class hierarchy:
public interface IHazardLocation {}
public interface IHazardLocations : IEnumerable<IHazardLocation> {}
public interface IClusterHazardLocations : IHazardLocations { }
[Serializable]
public class ClusterHazardLocation : IClusterHazardLocation
{
public ICluster Cluster { get; }
[UsedImplicitly]
public ClusterHazardLocation()
{ }
public ClusterHazardLocation(ICluster _cluster)
: this()
{
Cluster = _cluster;
}
}
[Serializable]
public class ClusterHazardLocations : IClusterHazardLocations
{
[NotNull]
private readonly List<IClusterHazardLocation> m_Locations;
public ClusterHazardLocations()
{
m_Locations = new List<IClusterHazardLocation>();
}
public ClusterHazardLocations([NotNull] params IClusterHazardLocation[] _locations)
{
m_Locations = _locations.ToList();
}
public ClusterHazardLocations([NotNull] IEnumerable<IClusterHazardLocation> _locations)
{
m_Locations = _locations.ToList();
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<IHazardLocation>)m_Locations).GetEnumerator();
}
public IEnumerator<IHazardLocation> GetEnumerator()
{
return ((IEnumerable<IHazardLocation>)m_Locations).GetEnumerator();
}
public void AddHazardLocation(IHazardLocation _other)
{
if (_other is IClusterHazardLocation tmp)
{
m_Locations.Add(tmp);
}
}
}
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
modified 8-Feb-21 10:12am.
|
|
|
|
|
Is this something you can recreate with a simple dummy project? If it's something you could upload to github, I'd enjoy having a look at it.
|
|
|
|
|
Thanks for your help. Unfortunatey, it's too big...
Do you have some similar situation some where:
- a class which inherits IEnumberable, but does not derive from List/Array etc, instead contains a List
- can be transferred via WCF
- now add an "Add" method
I am not sure if those are already all the required steps.
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
I meant a simple repro of the issue rather than the thing itself.
|
|
|
|
|
What Pete is suggesting is a dummy project to prove where the fault lies: create a minimal sample that doesn't have the problem, add the Add method and see if it fails. If it does, put it up on Github for examination.
If it doesn't ... then the Add addition is probably coincidental, and you broke something else at the same time!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: the Add addition is probably coincidental, and you broke something else at the same time
Absolutely sure: by renaming "Add" to "AddHazardLocation" the problem was solved.
I did the analysis step by step - tedious minimal steps. Nothing else was changed at that moment.
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
Creating "empty" interfaces seem questionable to start with.
public interface IHazardLocation {}
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
|
|
|
|
|
I wrote some codes in DevExpress spreadsheet which gets information from a sheet and then put them into a dictionary and after that do some calculations and at the end creates a new sheet and fill the cells with calculated data.
I want to use a progress bar for the whole process. I created a progress bar and tested it with a sample value of 50. When the calculations start, progress bar is in freezed status and shows nothing. When the background calculations end, the progress bar unfreezed and show 50%.
How can I solve this problem?
modified 7-Feb-21 22:28pm.
|
|
|
|
|
Please explain how you're running the background task, and how you let it report progress updates to the progress bar.
|
|
|
|
|
I'm going to update the progress bar based on each row is filled at the new sheet. I tried to test it with a constant value of 50 and noticed that it freezes until the end of the calculations. The calculations consist of the following steps: 1. Data is read from a sheet into two Lists. One list is string type and another is integer type. String type list consists of values of 4 cells in each row.
2. Lists are put into a dictionary. Strings are keys and integers are values.
3. Values of the same keys are summed.
4. The mentioned two lists are cleared and fill by dictionary keys and values.
5. Dictionary keys and values are split into cells in a new sheet.
modified 7-Feb-21 22:38pm.
|
|
|
|
|
_ = Window.Current.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => {
} );
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
|
|
|
|
|
When you execute a lengthy operation (any computation exceeding say 50 msec, but also anything that might occasionally be slow, e.g. an internet access) in one of the GUI event handlers (e.g. a button's Click), it will block the main=GUI thread, as a result your GUI freezes.
There are a number of bad attempts to fix this. The good ones all involve another thread, but then, beware, other threads are not allowed to touch your GUI Controls. The recommended approach is by using one BackGroundWorker; it will perform the bulk of the job on a separate thread, yet it provides a progress reporting event which automatically does run on the main=GUI thread, so that is by far the number one way to keep your GUI alive and responsive.
When the BGW finishes up, it fires a Completion event which typically is used to report all mishaps that may have occurred (make sure to handle its Exception which unfortunately there is called Error), it could also be used to e.g. re-enable a Button; that event handler also runs on the main=GUI thread, again no worries.
If unfamiliar with BGW, look for (a) the documentation and (b) a good example, and study these first. It may seem complex, but it isn't; it is the easiest way into multi-threading, something most applications are bound to take advantage of.
Luc Pattyn [My Articles]
If you can't find it on YouTube try TikTok...
|
|
|
|
|
I have a C# console application that is launched from a WinForm application.
The output of the console application is well-formatted; however, user can run the console application directly. Is there a way to restrict/force the console application to be only run from the main application (WinForm)?
|
|
|
|
|
Pass a mystery parm to the console app that only the Windows Form knows about. No parm, no run.
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
|
|
|
|
|
You can easily get the command line parameter from Task Manager, so the passed value should be changed every time it needs to be launched. I was thinking the parameter could be randomized or something else, then verified over a named pipe, or other IPC, with the WinForms app.
|
|
|
|
|
I was counting on the "user" being "typical" ... Task Manager? Wazzat?
This looked like an "inhouse" solution ... Anybody trying to bypass this simple solution is obviously asking for trouble.
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
|
|
|
|
|
The thing about your "typcial" user is that some of them stumble across how to do things they shouldn't normally know how to do.
NEVER assume users stay uninformed. Security is only secure in an environment that never changes or is touched from the outside, and that's never the case.
|
|
|
|
|
There's a difference between "accidently" running a console app versus defeating a method intended to prevent "accidents".
Yes, there is a chance someone will type: ConsoleApp.exe supercalifragilisticexpialidocious.
There is also such a thing as overkill based on what the console app actually does.
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
|
|
|
|
|
Oh I get it, I've been here before. I speak from experience I cannot talk about.
|
|
|
|
|
One size does not fit all.
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
|
|
|
|