|
|
I'd just like to reinforce the answers that say your security policy is broken here. Either you trust your staff, in which case you don't need a monitoring service that they can't kill, or you don't, in which case they shouldn't be admins. You are searching for a technical solution to a HR problem.
The simplest approach here is to make disabling the service a disciplinary offence.
Edit: also, this really isn't a C# question.
|
|
|
|
|
candogu wrote: I need to make a windows service that will return Access is denied when a user
in admin group
To answer another way, Don't, just don't, oh for the love of humanity don't.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Okay I found the solution. I give blue screen error when a user even administrator tries to kill my process and service and it cannot be stopped for now according to my tests. However, system doesn't normally shutdown by the service. Windows gives blue screen error from service side when I try to shut down or logoff. From windows process I detect SessionEnding event and I close my application under my control but from service I cannot detect SessionEnding event. What can I do here? What should I use instead SystemEvents? From CSHARP
|
|
|
|
|
The problem with your solution is that you will blue screen whenever anything causes the service to stop, including the service erroring out. As you have been told, the only way to accomplish what you want is to use the Access Control List (ACL) to say who can do what with the service. But seriously, the advise we gave you is good advice - we aren't ripping into your question, we are telling you that from real life experience, relying on users having admin privilege is dangerous.
|
|
|
|
|
I know that but I have nothing to do with that because I am not the manager okay. Finally I solved my question myself. When computer is shutting down or session is ending, I detect it and I disable critical system process. And windows can normally shutsdown and logs off. How can I set ACL? When I set ACL, can administrators kill my service? Thanks.
|
|
|
|
|
how to prepare synopsis for Resource Sharing and Conflict Management System
|
|
|
|
|
Is this a C# question? If so please give some more detail of the problem you are trying to solve.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
How to prepare?
Well, that starts by getting a definition for those terms. Then you'd decide the scope of your synopsis. How far are you at this point?
Bastard Programmer from Hell
|
|
|
|
|
I am working on some code to replace all of the LF end of line chars with CRLF in a text file. I wanted to account for the scenario of if the file does contain CRLF already and am not sure how. My current code will replace CRLF with CRCRLF which is not good. Does anyone have any ideas? Thanks in advance for your assistance!
string data = null;
using (StreamReader srFileName = new StreamReader(FileName))
{
data = srFileName.ReadToEnd();
data = data.Replace("\n","\r\n");
}
using (StreamWriter swFileName = new StreamWriter(FileName))
{
swFileName.Write(data);
}
|
|
|
|
|
One easy method would be:
data = data.Replace("\r\n","\n");
data = data.Replace("\n","\r\n");
But thats doing two replaces which might be a performance issue.
Another method I think should work is to use File.ReadAllLines() followed by File.WriteAllLines().
Yet another method would be to use regex to match \n's that are NOT preceeded by \r's.
|
|
|
|
|
Hi every body
I want to send email in windows application.
when i trace code all is OK but no message is received in mailbox ,my code is below:
MailAddressCollection receivers = new MailAddressCollection();
MailMessage msg = new MailMessage();
msg.IsBodyHtml = true;
msg.From = new MailAddress("telavat@telavat.com", "Alireza Doroudian");
msg.To.Add("a.doroudian@gmail.com");
msg.Subject = "testofHtml";
msg.Body = "ww";
SmtpClient smpt = new SmtpClient();
smpt.Host = "localhost";
smpt.Port = 25;
smpt.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smpt.Send(msg);
thanks for any guides
Regards
Ali
|
|
|
|
|
My first suggestion would be to remove your email addresses from your post . You are about to getting spammed into oblivion as spammers spider this forum for addresses.
|
|
|
|
|
smpt.Host = "localhost";
Do you have an SMTP server running on your localhost machine? The smtp host target needs to be a system that is running a mail server and can transport the mail message to its destination.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Use this class to send email on windows application:
public class Email
{
public void SendEmail(string userName, string password, string mailFrom, string mailTo, string subject, string message, bool isBodyHtml, string SmtpAdd, int port)
{
MailMessage msg = new MailMessage(mailFrom, mailTo, subject, message);
msg.IsBodyHtml = isBodyHtml;
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential(userName, password);
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient(SmtpAdd, port);
mailClient.EnableSsl = false;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = cred;
mailClient.Send(msg);
}
|
|
|
|
|
Hi All,
I have got stuck with some issue with export option of gridview to excel sheet. Kindly help me is sloving the porblem. Attachments are not coming in the excel exported.
Thank you.
Here is code
public void Export(string fileName, GridView gv)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
Table table = new Table();
table.GridLines = GridLines.Both;
if (gv.HeaderRow != null)
{
PrepareControlForExport(gv.HeaderRow);
table.Rows.Add(getheader());
table.Rows.Add(gv.HeaderRow);
table.Rows[0].BackColor = System.Drawing.Color.FromArgb(37, 96, 133);
}
foreach (GridViewRow row in gv.Rows)
{
PrepareControlForExport(row);
table.Rows.Add(row);
}
if (gv.FooterRow != null)
{
PrepareControlForExport(gv.FooterRow);
table.Rows.Add(gv.FooterRow);
}
table.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
}
private static void PrepareControlForExport(Control control)
{
for (int i = 0; i < control.Controls.Count; i++)
{
Control current = control.Controls[i];
if (current is LinkButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as LinkButton).Text));
}
else if (current is ImageButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as ImageButton).AlternateText));
}
else if (current is HyperLink)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as HyperLink).Text));
}
else if (current is DropDownList)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as DropDownList).SelectedItem.Text));
}
else if (current is CheckBox)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as CheckBox).Checked ? "True" : "False"));
}
if (current.HasControls())
{
PrepareControlForExport(current);
}
}
}
|
|
|
|
|
Hello,
I am developing an all which requires me to update the screen rather often. At the moment it is set to 1 second, I can change it, but i wouldn't want to move it much past 5 seconds.
At the moment I have a BackgroundWorker doing the TableAdapter.Fill(), and then I am clearing the DataSet and Merging it for the final outcome. However, this is slow enough to block the UI, making things very jerky.
I tried moving the clear and Merge to the background thread, however when I did that it throws errors when you try to interact with the DataGridView whilst it's updating.
Any ideas?
Thanks,
Brendan
|
|
|
|
|
Not possible to have a real time app polling a database, sorry . Rethink your design. I don't even know what your app does, but I'm guessing its not changing the entire table every second. Rethink your approach. You will likely need to write an IOCP based UDP server to be able to keep up with real time updates on multiple clients and stop sending entire tables to the client. Its not necessary. You just need to send new data.
|
|
|
|
|
Basically my app is a monitoring application for status codes on alarms. The reason I need fast refreshes is that the application needs to see when the other operators do things - i.e. acknowledge a status code, etc.
Ahh, bugger. I was hoping the apps could talk directly to the SQL server itself. I'll look into your suggestion though! Thanks!
|
|
|
|
|
I think there is such a thing as wiring up events between sql server and c#. I have never pursued this info as I find the concept horrifying!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes, SQL is able to call code or COM objects, etc. It is NOT intended to be used as a push mechanism to multiple clients. Thats even stated in the docs. Its intended to be used as a notification mechanism for a single server process. More efficient then hitting up the database every second, but he's still going to need a server piece in which case he might as well "do it right" .
|
|
|
|
|
I have never actually read the docs, not something I would recommend to anyone, live updates of data changes from the server yech!
If you were running WCF could that act as the choke point monitoring all changes rather than the TCIP suggestion you put forward?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Nah, WCF sucks. I will never use it again. It is easy to implement though. We have a couple of WCF components in my current project (not my idea!). WCF is slow (too much XML traffic) and has no push mechanism. I don't think WCF would scale too well either. The only thing that scales into 10's of thousands of connections per server is going to be TCP/IP (or UDP) using IOCPs. Not sure if the OP has to go that far though .
|
|
|
|
|
Gotcha. Yeah, I don't think polling the database server constantly is going to work very well with multiple clients . Since you probably don't want missed updates, I'd probably go with TCP/IP vs. UDP. Although UDP wouldn't necessarily be a bad thing here. TCP/IP is probably going to be easier to implement a reliable system with though. Your design would probably be that everybody connects to the TCP/IP IOCP server through a simple text or binary protocol you invent. When somebody updates something, you push the update out to all the clients. The TCP/IP server would be the only process writing stuff to the database in the background.
|
|
|
|
|
I am just wondering if there is a pattern for programming conditions which are not known by the programmer at programming time; i.e. the conditions are set by the user.
For example, the user may define a set IF conditions, and corresponding actions. If the IFs were finite, that would be easy. However, the user has a variable set of conditions/rules. A good example of this is a ERP-purchasing module application. The routing of a purchase order depends on approval level. The levels of approval are determined by the company policy. There could be any number of approval levels.
In other word
IF condition 1... then action 1
IF condition 2... then action 2
..
IF Condition n.... then action n
but N is unknown at programming time. So I can't use the the typical if-else block.
Any suggestions on how to handle this.
|
|
|
|