|
The way to do this is to use a design pattern (or two). I'm thinking here specifically of the Model View Controller pattern. Read up on this as it's going to be your best friend here. As a taster though, I will tell you that the MVC pattern allows you to have one model with multiple views of the same model so you will update the model and the views will be updated to match. I'm sorry, but I can't give you the code for this because it is a fairly complex design architecture that you need to get to grips with and it's more code thank I could give you in such a short space.
|
|
|
|
|
Hello.
I have developed a simple communication system as a website where my site users can send messages to each other after logging in. I store the messages in SQL Server. I store the subject, body and other common properties of a message. What I need now is to make my web application POP3- and SMTP-enabled. So that I not only store my messages in my database, i prove my users with email addresses on my website like user1@mydomain.com, so that incoming emails to this address, will be intercepted and I can show each user his messages. Also they can send messages, not only to the internal users of my system, but everybody who owns an email. I think I should let my application talk in POP3 and SMTP language.
On the net, I found some useful articles. One described how to use socket programming to save the message on the server side in a folder. But the problem is that who is gonna send it at the end? IIS? But what if I myself want to send it? What should I do to send a queued message to the recipient's address?
Please if anybody has any experience in this field, help me out.
Thanks in advance.
|
|
|
|
|
Hi Hamid,
what you want to implement is called a 'mailserver'.
There are 2 possibilities to realize that :
1. If you want to reinvent the wheel : You can write your own server, but you should be aware, that
this is NOT trivial. There will be at least 2 protocols you have to implement (SMTP & POP3) in
addition to all the internal handling. If you plan to do something like that, I would recommend
to have a look at the RFC's first so that you have an idea what that means.
A collection of RFC's can be found here :
http://www.rfc-editor.org/rfc-index2.html
2. You can use an existing product. There are several commercial and non-commercial systems available.
Here are just a few links, to some existing solutions :
Lumisoft Mail Server
mail Enable
Hope, that helps a bit ...
Sven
|
|
|
|
|
Check out the System.Net.Mail[^] namespace. It has a bunch of good stuff that might help you with your problem.
|
|
|
|
|
I have an MS Access DB and a desktop application which I want it to check for the new items on the database and print. right now i am able to check the database and see the new items, but I dont know how to refresh it on the desktop app.
I want to check the db ( lets say) every 2 mins for new items on the list.
private void TheJob()
{
DataAccess da = new DataAccess();
string sql = "SELECT COUNT(*) FROM read WHERE [New?]=true";
string tmpValue=da.GetValue(sql);
NotifierInfo.Info = "You have " + tmpValue + " clients waiting";
NotifierInfo.ShowInfo();
How can i check the database every 2 mins for new items ? Thanks
|
|
|
|
|
You should have a look at the timer class (System.Windows.Forms.Timer).
An article about how to use it can be found > here < ...
Hope, that helps ...
|
|
|
|
|
Hi,
I'm implementing the .net Backgroundworker without any big issues.
But I don't really like to have to parse (box, unbox etc) the DoWorkEventArgs argument.
Shouldn't I be able to Inherit from this class to make my own?
When I do so, I get the No overload for method 'DoWorkEventArgs' takes '0' arguments error.
What am I doing wrong? I feel like I'm doing something shamefully wrong with inheriting in general ...
|
|
|
|
|
You could create your own args, but it'd do you no good unless you built your own BackgroundWorker that created your args.
boersnoes wrote: But I don't really like to have to parse (box, unbox etc) the DoWorkEventArgs argument.
No boxing or unboxing is going on, unless you're storing a value type in the Result or Argument of the args. Anything else is just casting, which is fine by performance standards.
|
|
|
|
|
Well, currently I have to do this:
<br />
string from = (string)((object[])e.Argument)[0];<br />
string to = (string)((object[])e.Argument)[1];<br />
string fileName = (string)((object[])e.Argument)[2];<br />
This looks like boxing to me, but correct me if I'm wrong.
Furthermore, I can't rely on all the arguments being there.
When I call the method I have to do like this:
<br />
syncWorker.RunWorkerAsync(new Object[] { fromDir, toDir, fileName });<br />
This requires the consumer of my methods to know what arguments are required and what order they ought to be in.
So either there has to be a better way of passing arguments on, or I have to create my custom DoWorkEventArgs.
|
|
|
|
|
That's not boxing, that's casting. Boxing would occur only if one of the arguments in there is a value type (a struct) such as an int, double, etc.
Here's what I recommend. Don't pass in an object array as the argument. Instead, create a custom class that contains your data, and pass that in as the args:
class MyArgs
{
string From;
string To;
string FileName;
}
....
syncWorker.RunWorkerAsync(new MyArgs(from, to, file));
...
void OnDoWork(DoWorkEventArgs e)
{
MyArgs args = (MyArgs)e.Argument;
}
|
|
|
|
|
Hi, can someone help me out ?
I have a line of code in the cellClick of a datagridview.
<br />
System.Diagnostics.Trace.WriteLine("Cell Click before");<br />
this.DoDragDrop(DgLevels.Rows[e.RowIndex].Cells[DbCnst.Lev_ID].Value.ToString(), DragDropEffects.Move)<br />
System.Diagnostics.Trace.WriteLine("Cell Click after");<br />
But when clicking one time on the cell, "Click before" appears in the output window, but it takes almost a second before "click after" appears.
it also doesn't work like it should be. seems like it switches the drag and drop.
click (drag)
click second time and nothing happens, even when event is fired.
looks like there is a timeout for the drag and drop.
do i need to cancel it ?
thx
Kurt
|
|
|
|
|
OKay, my fault.
I should have used the cellmousedown..
So this works better.
Still one problem, it doesn't show the drag icon immediatelly, only when i start moving the mouse.
greetz and merry Xmas
Kurt
|
|
|
|
|
Any webproject after build/rebuild/deployed it is taking more time to load the first page.
if we close the page and agian opening the page , it is showing very fastly
we are using Ajax, Infragistics in our project.
i think it is loading all dll in memory when loading first time.
how can we overcome this scenario that means can we load the dlls asyncronously so that user will not feel the late page loading or is there any option in .net.
|
|
|
|
|
This can be attributed to Just-In-Time (JIT) compilation occurring the first time the application is run. JIT compilation is a core feature of .NET so I suggest you read this article[^]to learn more about it.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
The delay is caused by IIS dynamically compiling the application on the first run after it is rebuilt. You'll also notice this happening if you stop IIS and start it again.
I personally don't think this is a big problem, and this approach provides a number of advantages. However, if it is a big issue for you, have a google for pre-compilation in ASP.Net 2.0.
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
Is it possible to update Embedded resource file dynamically?
can we add a new Embedded resource file dynamically?
Please Provide some samples
|
|
|
|
|
No. Since the resources are compiled into the .EXE and the .EXE file is locked for the entire time your app is running, you can't modify the file.
|
|
|
|
|
Couldn't you do the following...
1. Exe1 starts running, with resourceA in it
2. Exe1 spawns Exe2
3. Exe1 is killed (either by Exe2 or it kills itself)
4. Exe2 modifies resourceA in Exe1
5. Exe2 spawns Exe1
6. Exe2 is killed (either by Exe1 or it kills itself) The step in question is step 4, as the others are pretty well defined. Is there some way to perform that step?
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
|
This would work. It requires that your .EXE talk to another and pass what it needs to do to the 2nd .EXE.
It is possible to modify the resources, but with great difficulty. There may be a 3rd party library out there that can do this, but I haven't found one. Not that I would want to do this myself. I'm of the opinion that if you feel the need to have your app edit it's own resources, then you really need to rethink your design.
|
|
|
|
|
I would agree that this is not the standard way to go about doing things, but I can think of a time when it would be useful (and perhaps desireable) to have a second app modify the first: an auto updater application. If you change a binary by only modifying an associated resources, then an automatic updater should be able to only download that resource instead of the entire binary file. I think this use, although rare, is completely appropriate for such a methodology. Just my two cents. Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Skippums wrote: but I can think of a time when it would be useful (and perhaps desireable) to have a second app modify the first: an auto updater application.
I didn't say that was the problem. The problem was changing the resources of the target .EXE without damaging the .EXE. The file would have to be rewritten, at least partially.
Skippums wrote: If you change a binary by only modifying an associated resources, then an automatic updater should be able to only download that resource instead of the entire binary file.
This technique is used to do byte-patches of applications, but not normally to modify the resources of an .EXE in the normal course of the execution of the app.
I'd day that if you had to modify the resources, compiling the resources into a seperate .DLL would be the safer way to go, as well as being more flexible in the case of localized versions of the resources.
|
|
|
|
|
Hi every body,
Sandeep here.I'm a very big fan for .net applications. I'm have zeal to know new types of programming. In this process i came to know that "the code project" is a very good website to achive my goal.
Here my question is : Recently i took one source code on c# application. having so many files including ".dll" files also. Now i need to use these .dll files in my application. Can i use or not. is it a legal thing or not.
Pls mail me regarding to my question above stated.
my communication mail id is : sandeepgrt@gmail.com
Expecting response from all......................
|
|
|
|
|
Where are you getting the dlls? Check the licenses of the code you are using.
|
|
|
|
|
It is best to not put your email address in a post.
Sandeep kumar M wrote: having so many files including ".dll" files also. Now i need to use these .dll files in my application. Can i use or not. is it a legal thing or not.
Depends on the licensing of each of the .dll's. Are they ones you created or got from other sources?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|