|
Hello,
I'm totally new to distributed applications and i need help with:
- How do i expose C# windows service procedures so the they can be called remotely??(or is it the same as declaring procedures normally and just adding a referece to the windows service??)
- Learning how to tell when Remote Procedure Call's are made to a C# windows service so that the procedure executes using the parameters supplied.
thanks,
Afzal Hassen
|
|
|
|
|
A bit trifle to the experienced, this question probably is!
Say one is building a multi tier application:
web-front
business-logic
database
Going backwards:
1 - user clicks to get some info from the database.
2 - request is handled on the server
3 - business object is instantiated to process the request
4 - data access object is instantiated to retrieve the data
5 - user satisfied.
So the questions are:
1. Does 3 and 4 happen every time? The objects get instanciated? Or should the object be maintained in memory for the next call?
2. The data retrieved (dataset or should I say view) contains a lot more info (is complete in other words) before the business logic is applied. Shouldn't this dataset persisted in some way to be reused instead of making expensive calls to the database?
Now I may have the lines between the tiers wrong. So can someone elaborate?
A practical example would be nice (not code just pseudo).
|
|
|
|
|
Anonymous wrote:
1. Does 3 and 4 happen every time? The objects get instanciated? Or should the object be maintained in memory for the next call?
Depends on how much memory those object consume and how expensive it is to create/destory them. And another thing to take into consideration is the number of time this will happen. If you have a busy website with a lot of user requests then it would make sense to persist something on the backend for a while. On the other hand if you only have a handful of request then its safe to keep on recreating them. Recreating them is also safers because your object will not retain state from a revious request and chances are much smaller that things will get stale since you are working on a freshly created object. Besides with the speed on modern hardware you should not encounter any problems constantly recreating and destroying objects.
Anonymous wrote:
2. The data retrieved (dataset or should I say view) contains a lot more info (is complete in other words) before the business logic is applied. Shouldn't this dataset persisted in some way to be reused instead of making expensive calls to the database?
Calls to the database are not that expensive anymore. Correction, if you know to use the right way to access the right database then this operation is not that expensive. For example; if you use a SQL Server as your database then you should use the SqlConnection, SqlCommand and SqlDataReader object to work with it. By using these objects the developers at Micosoft guarantee that you will have the fastest means of accessing data from the database. If you use an OdbcConnection, OdbcCommand and OdbcDataReader, even though SQL Server will understand your request, the results will be slower then by using the native Sql* objects.
Also there is a big difference between a DataSet and a DataReader. When reading data from a database through a web application it is very rare you would use a DataSet. DataSets can be slow and can require a lot of memory because a DataSet will read all the data from your database and keep eveything retrieved in memory. I would recommend using a DataReader instead. DataReaders don't create a local copy of the data you requested in local memory because they keep an open connection to the database and only retrieve data that you need at the moment. A really good article about this subject can be found here:
http://aspnet.4guysfromrolla.com/articles/050405-1.aspx
|
|
|
|
|
Excellent Article indeed! Appreciate the suggestion.
So data reader is the way to go unless it is absolutely necessary to use a dataset. On a tangent, this is also true for reading xml using the pull model in the framework with XML reader instead of loading the XMLDocument in memory.
I had also hoped that someone would put this scenario into multi-tier model for me, as I am still confused as where the separation is. For example, my aspx page will have the code-behind page - is this where I would type in my queries and interact woth my data-reader/dataset and process them or would I use pre-written classes(containing the logic for quering the data) and pre-defind methods like "get-product-by-id" etc., which I would instantiate in the code-behind page and pass the parameters to be processed withing those objects and return the results? Guess I am after "best-practices" here in designing a web-application that is scalable and reusable.
Furthermore, everyone of those objects (like dataset/datreader/adapter) are objects already, so is wrapping them necessary?
If someone can put this in perspective or suggest an article, I would appreciate it. Googling brought in results that are either too simplistic or too thoretical.
And Thanks Peter for taking the time to explain.
|
|
|
|
|
Hi buddies,
How to get the video srteaming details of an user from Flash communication server using C#?
is it possible???
it is very urgent...please help with a sample code or any article..
Thanks,
Vinu
|
|
|
|
|
Hi there,
I'm just wondering is there anyway possibly about windows control's events make happen in code? Not in Form..
As if it is user click button on form during the execution of code
Just like custom event make it happen ... or some other ways?
private void doSomething()
{
//Some code...
btnButton.Click(null,null);
}
|
|
|
|
|
Always you have a windows control's event you have a delegate function.
Try to call the delegate.
this.btnButton.Click += new System.EventHandler(this.btnButton_Click);
...
private void doSomething()
{
...
btnButton_Click(null, null);
...
}
Is that you want?
|
|
|
|
|
nope.. I already got solution..
btnButton.PerformClick()
Thanks anyway..
|
|
|
|
|
Hi
I wand to develop a tri state Check listed box (That allows tickboxs to be in three states: ticked, unticked and crossed.) for a win form application.
There is no such control in the .Net,
shall any one suggest how to do or shall I get any sample code for the same.
Regards
|
|
|
|
|
Given that you need to draw and store three states ( and it's a pretty simple control ), I'd be inclided to create an enum for the state and derive a control from the absolute base class, and handle all events and drawing myself. Then I'd be inclined to write a CP article when I was done
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
1.Ex: textbox1:dd/mm/yyyy
textbox2:dd/mm/yyyy.
Now, i want to compare these,such as i require users must type into textbox which the date in textbox2 is lager than the second one.
So how do i do? Please tell me.
2.
The textbox must formatted datetime type(dd/mm/yyyy), but users can type mm/yyyy or yyyy.Is there any way to do this in C#? If not how way to do that?
study, study and study more
|
|
|
|
|
Hi,
To compare the dates you can use DateTime class's Compare method.
To format the text box i guess the following link will help you.
http://www.developersdex.com/vb/message.asp?p=2927&r=4036244
Thanks and Reagrds
SGS
|
|
|
|
|
Why not use a datetimepicker, and then you can set the second one to have a minimum date of the value of the first one ? Then you also get a datetime without having to parse it, although parsing it is not that difficult. If you split the string on the slash and count the number of elements, you'll know which of the three formats your user has attempted. I always think it's better to use a control that stops the user from making a silly mistake, if possible.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I can't using DateTimePicker. I writing WebApplication not WindowApplication. Any way? Please help me!
study, study and study more
|
|
|
|
|
|
As well as the calendar web control, there are a number of javascript date time pickers around you could use.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have been reading about how you can write your server such that client calls can block at the server, thus awaiting something back (say, a heartbeat msg or some otehr kind of update message).
I am not an expert in threading, and I was wondering how this can be accomplished. I have a cserver that needs to pulse all connected clients with update messages that can be processed on the client's end. I am not able to purchase someone else's remoting framework that claims to be able to accomplish this when its something that can be accomplished for free with reasonably-skilled coding.
Please, any ideas would help me.
|
|
|
|
|
OK.
If its that simple (sending update information) you could use the following approach:
a) A website which has an XML-File with product information
Say: http://update.mycompany.com/autoupdate/products.xml
Contains: <product>
<name>ABC Tool
<version>1.2.3
<location>http://update.mycompany.com/autoupdate/ABCTool/setup_ABCTool_v123.exe
for each product.
Use WebRequest and WebResponse to retrieve that HTML-File, parse it, download (using Request and Response again) it, Process.Start() it.
Thats client initiated and will pass most NAT-Routers and Firewalls, as this uses HTTP. You may want to use HTTPRequest instead, try both, im not sure which one is the right choice.
Another approach:
Every client registers with the server on program start and unregisters on program termination. The Server stores that information in an arraylist and informs all clients on upgrades.
You can do that by calling the asynchronous methods for Socket.Send (BeginSend and EndSend, I believe) for each element of your array list.
Information on how to create client/server applications also is available in the MSDN Docs.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
hi all;
i got a serious problem; iam making network application and am tring to send udp messages from any node on internet to node in local lan who has access to internet through serial router. the problem is when i started to transmite messages i found that i recieves his messgaes but he can't. when i traced the program i found that his ip and port is diffrent than what i bounded it on. of course the ip is the external ip of lan to connect to internet but the surprise here is even port changed!!!!!!!. i can know from udp socket the ip and port of sender but i need to know before sending or recieving becouse there is main server who control all operations and sends those info between node to communicate.
so my question is how can i know virtual ip and port of node in local lan who deal through them to internet?
thx for your time.
marcoryos
|
|
|
|
|
I have a form where a user inputs into a few fields and I validate them for correct format ect..
I do a e.Cancel = true; in my Validating event.
I can put a e.Cancel = false; into my FormClosing event to get it to close with out prompting for correction in my fields.
my problem is that I can't get a "close" button to do the same as the close (top right X) on my form.
How do I set the "e.Close" to false or essentially the samt for my form in whole?
Thanks,
H
|
|
|
|
|
Hi hhrafn,
Do you want to close the form or not? Whats your requirement?
Thanks
SGS
|
|
|
|
|
I'd like the form to ignore the validation requirements and close the form. For now the e.cancel feature doesn't allow me to close a form via a close button.
I can only close by hitting the X in the top right corner. Probalby because there I can access the event that supports this cancel feature and I can set it to false.
|
|
|
|
|
Set the Button 's CausesValidation property to false .
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Cool!
Thanks!
works great
love the little simple solutions
|
|
|
|
|
Hi
I have un over problem. Wheni close the form with Top Right X it fire the validating event of the textbox.
Did you change any property of the form, that it don't fire this event
Help me please
|
|
|
|