|
JD86 wrote: So if the application crashed (it shouldn't.. but you never know) or if the process was killed for some reason.... it won't be running anymore.
OMG
..imagine, someone like me, cutting the power to the PC. Would the program still run? Is the app there to help me, or is it there to be some kind of nuisance?
A task that is really 'unkillable' should prevent the PC from event rebooting, shouldn't it?
What you say you make submitting a ticket very easy? With a nice webform and an easy to remember-url? Wouldn't that be providing more of a service?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I don't really get what you are trying to get out nor do I care for the way you are coming off.
I work in a IT business. We have clients that we manage their computers. One thing that we want is a systray icon to make it easy for customers to submit a ticket.
A Windows application is better in this case instead of a web application. For one the web application would let anyone use it (we don't want it). If we locked it down by username and password then that is just an extra step for the user (we don't want an extra step for the user).
With a windows application a user can EASILY click a button to take a screenshot that has the error message on the screen. With a web application this would not be easy if possible (maybe with installing some active-x crap or something).
With a windows application & systray icon a user can simply right click an icon on their desktop and choose "Create Service Ticket". With a web application they would have to type in the URL, click a shortcut on their desktop, wait for the page to load and submit the ticket. Now you are dealing with more overhead since you are using IE, Firefox or whatever browser you are using. Which in turn uses more memory.
So if you want to get technical then a web form for submitting a ticket is less ideal than an application that we can push out with our monitoring service.
Anyways I'm not going to worry about something to make sure the process is running at all times. I think it will be a rare occurrence when it isn't running anyways... so we can just deal with that when it comes.
I appreciate the others that gave constructive feedback. Thank you.
|
|
|
|
|
JD86 wrote: nor do I care for the way you are coming off.
Sets the tone just nicely
JD86 wrote: A Windows application is better in this case instead of a web application.
With a windows application a user can EASILY click a button to take a screenshot that has the error message on the screen. With a web application this would not be easy if possible (maybe with installing some active-x crap or something).
Good point. I pointed out the possibility of a simple webform, as a browser is even available on most phones. It's easily accessible, and has a low threshold for the user. You're right that screenshots are invaluable when providing assistance. Same goes for having TeamViewer on there and having access to the log-files.
JD86 wrote: So if you want to get technical then a web form for submitting a ticket is less ideal than an application that we can push out with our monitoring service.
..that sounds like it's got more features than making screenshots?
JD86 wrote: Anyways I'm not going to worry about something to make sure the process is running at all times. I think it will be a rare occurrence when it isn't running anyways... so we can just deal with that when it comes.
Given the background, you do. I'd advise to try and "make it easy to submit" for a user; that's a bit broader focus, and could contain something like making your app easily restartable. My parents are using a shortcut to start their TeamViewer - it needn't be always on, as the shortcut is on the taskbar.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi
I'm struggling with how to structure this project in relation to base/generic/abstract classes.
Basically I was asked to write something quickly to rename some files (e.g. "File 00123 F Bloggs") to extract the number and rename the file as that, i.e. "123". Thinking this was a one off I created a simple exe. Then I was asked to do it a few more times for different files (e.g. "NewFile 045 F B") to "45". The function is the same except it checks what the filename starts with to make sure it is only renaming those files. So I thought I'd write a generic renaming tool and just take in a parameter for the start of the filename to check.
However, then I was asked to rename files to a different format (e.g. "Info 123 (24-08-2012)") to "INF-CD-20120824". So obviously for this the function is different.
I decided to call each renaming option, a Profile.
I thought I could create an abstract base class with the common functionality for Rename(...), but then override it in derived classes when a custom version was needed.
But I also just want to be able to call _profiles.CurrentProfile.Rename(...). But how can I do that when CurrentProfile might be of different derived types?
Am I approaching this right with an abstract base class or should I be taking a different approach?
Can provide rough source if needed.
Thanks
modified 12-Oct-12 11:00am.
|
|
|
|
|
UCLAdam wrote: Am I approaching this right with an abstract base class or should I be taking a different approach?
Nope, sounds about right.
UCLAdam wrote: But I also just want to be able to call _profiles.CurrentProfile.Rename(...).
As long as the object implements the member with the name "Rename", that should work. Your main application would still be working with that base-class, calling methods on it. You could use a strategy-pattern to decide which derived class gets instantiated;
namespace bla
{
abstract class DuckBase
{
abstract public void Rename();
}
class RubberDuck: DuckBase
{
override public void Rename()
{
Console.WriteLine("Squeek");
}
}
class MallardDuck : DuckBase
{
public override void Rename()
{
Console.WriteLine("Quack");
}
}
class Program
{
enum KindaDuck { RubberDuck, MallardDuck };
DuckBase DuckFactory(KindaDuck DuckType)
{
switch (DuckType)
{
case KindaDuck.MallardDuck: return new MallardDuck();
case KindaDuck.RubberDuck: return new RubberDuck();
}
throw new IndexOutOfRangeException(DuckType.ToString() + " is not a known duck.");
}
static void Main(string[] args)
{
DuckBase ducky = new RubberDuck();
ducky.Rename();
Console.ReadKey();
}
}
}
The only rule is that the Rename method must have the same signature everywhere. If that becomes a problem, call back again, as there's a simple solution
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy, your reply really helped.
I thought it would probably have to be a strategy-pattern to decide which derived class gets instantiated.
I know it must be intentional, but just checking that in your example the DuckFactory isn't actually being used?
Thanks again.
|
|
|
|
|
UCLAdam wrote: Thanks Eddy, your reply really helped.
My pleasure
UCLAdam wrote: I thought it would probably have to be a strategy-pattern to decide which derived class gets instantiated.
I know it must be intentional, but just checking that in your example the DuckFactory isn't actually being used?
Whehe, most important part of the entire pattern, and I simply forgot it
static void Main(string[] args)
{
DuckBase ducky = DuckFactory(KindaDuck.MallardDuck);
ducky.Rename();
Console.ReadKey();
}
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Do you suspect many more of those renames to be requested?
I think that you trying to do simple think even simpler. And you complicating thinks to much in the same time. I know this. We all know (developers) this trap.
Basically what I mean that if you are making single exe, every change must be change in code. You must open code, change it, add something. So writing complex OOP class structure will be time consuming. And not worthit since end user will not use configuration or parametrized arguments.
I would write something simple like RegExp for matching/extracting files names and string.format for creating new names. New profile, new reg pattern and new format string.
You never know what will come to mind of customer so i think any clever solution will restrict you to much, to that point you wil have to rewrite whole thing every time. Will it be wort it? I think no. Better spend this time doing more interesting things.
It is my experience, but you wil what you decide.
No more Mister Nice Guy... >: |
|
|
|
|
|
We have an app that needs to download some 20MB file via a GSM connection. Due to the size of file and nature of the GSM connection, we want the download can pick up and continue from where it dropped off. Any info or suggestions? Thanks!
Best,
Jun
|
|
|
|
|
Jun Du wrote: Any info or suggestions?
Yes, a thing called "research". Start here[^], and use a HttpRequest to fetch the desired byte-range. There might be an article on the subject, but I was to lazy to check
--edit
Another downvote for the collection. Was it that really that annoying that I did not check? Here's[^] your article - you're welcome
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
modified 12-Oct-12 19:43pm.
|
|
|
|
|
i want to change color.
If Groupbox enable fasle mode,.. then all text box, combo etc color change.
if Groupb box box enbale true,.. then no problem.
give me solution...
|
|
|
|
|
Hi,
Can you please clarify if the textboxes and comboboxes are located within the group box?
Cheers
Marco
|
|
|
|
|
textbox or combo with inside group box...
if inside groupbox control or not,
if define textboz1.enable=false;
then user define color not apply...
only enable false property does not take colour effect why?.
as like fore color, back color, border etc color and design effct.
other wise enable true,
user define color also runing on........
|
|
|
|
|
private void ReadDaqThreadProc()
{
dThreadCallback tcb = new dThreadCallback(ReadDaq);
while (flags.daqEnabled)
{
try
{
this.Invoke(tcb, new Object[] { }); }
catch (Exception e)
{
}
Thread.Sleep(50);
}
}
This snippet is part of a multithreaded app. "tcb" is a delegate, ReadDaq is a function in the MainForm code, and ReadDaqThreadProc is in its own thread. I know what the code does but I dont know how. I'd like to understand how this works. The line in question is the invoke line. Is 'new Object[] {}' an argument list for ReadDaq?
|
|
|
|
|
Yes, it's passing an empty object array (the default container for invoke-params) and calling "tcb", the ReadDaq method - a method without parameters. And it seems to swallow any exceptions, which isn't such a great thing.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
It should be in a try block?
|
|
|
|
|
Member 8461599 wrote: It should be in a try block?
Why? Which exceptions does the Invoke method throw? It's only there to ensure that any exceptions from the implementation of the method do not kill the application; and those exceptions should be handled there - locally; not here. Also, it's wise to "log" all exceptions, as a "swallow all and be silent" is a known point of failure. Sometimes an exception is thrown away that you did not expect, causing weird program-behaviour.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
If you'll forgive my ignorance... I guess I dont know what you mean by "swallow any exceptions, which isn't such a great thing".
My knowledge of C# isnt very deep, as you can see.
|
|
|
|
|
This code:
try
{
...
}
catch (Exception e)
{
} is called "swallowing an exception", because whatever error occurs in the try block will be caught by the catch block and discarded without any attempt to handle it, log it, or in any other way acknowledge that there is a problem that should be fixed, or at least investigated.
This is considered a poor programming practice, as it just masks problems that may become serious later. There can (occasionally) be a good reasons for ignoring specific exceptions, but these should be restricted to specific exception classes (such as ArgumentNullException, or FileLoadException) rather than a blanket "Exception" and commented thoroughly.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Ahh... Gotcha.
There actually is code there. I took it out when I posted it here.
|
|
|
|
|
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
The exceptions which could arise in the ReadDaq function will arise in a different thread - the thread of the GUI. You are not able to catch them here, hence you can omit the try-catch-block here. But ReadDaq ought to have its own try-catch.
|
|
|
|
|
Bernhard Hiller wrote: You are not able to catch them here,
No, not quite true (at all). The Invoke mechanism catches an unhandled exception within the target method and rethrows it in the calling thread. In doing this the stack trace containing the site of the original exception is lost. Whether or not something bad happens when the exception is rethrown depends on the caller. For example I've noticed that the thread used by a System.Timers.Timer to call the Elapsed event handler carries on obliviously with no hint of discomfort!
See the remarks section in Control.Invoke[^]
Alan.
|
|
|
|
|
not 100% sure, but you could pass null instead of new Object[]{}. The signature of the Invoke method requires an object array. This is actually used to box/unbox parameters for the threading function. If null is allowed (I think so) this is for me preferable, because it indicates we're passing it to fulfill the method requirement. passing a new Object[]{} not only initializes memory, but also might indicate we "forgot" to do something.
Hope this helps.
|
|
|
|
|
String snmpAgent = "ipAddressOfPrinter";
String snmpCommunity = "public";
SimpleSnmp snmp = new SimpleSnmp(snmpAgent, snmpCommunity);
Dictionary<SnmpSharpNet.Oid, AsnType> result = snmp.Get(SnmpSharpNet.SnmpVersion.Ver1, new string[] { "OidOfPrinter" });
if (result == null)
{
MessageBox.Show("Request Failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
foreach (KeyValuePair<SnmpSharpNet.Oid, AsnType> entry in result)
{
textBox1.Text = entry.Key.ToString() + " = " + SnmpConstants.GetTypeName(entry.Value.Type) + " (SysDesc.): " + entry.Value.ToString() + "->
here is the connection to the printer. I can get the name, properties, software etc. of the printer, but i cant get the status of the printer(if it is online, offline, toner level, paper status, etc.) can you help me to code this?
Thanks a lot for your ideas and helps.
|
|
|
|