|
It is acceptable that printing will slow down with much request (print queue is full), but I have a strong feeling that you do ot know what are you doing here.
Let see an example. Code Project has 'Terms of Service' page stuffed with legal do and don't do. Let imagine that you had a print button on this page. What would happened if on every click on that button a copy of that 'Term of Service' was printed in Toronto, Canada? What Code Project staff should do with all that prints? And what the CPian who asked to print will do without that important paper?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
even though it runs on server but the printer it picks is local to system and not related to server.
what i was asking was is there a better way of doing this instead of using interop's
|
|
|
|
|
Quote: the printer it picks is local to system You are kidding, right?
How on earth the server knows about locally installed printers!!! Imagine that you are browsing a site that hosted on a server in the UK, should that server know anything about your hardware setup and installed drivers in you office in India?! Think about it!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
nitin_ion wrote: but i don't feel it is optimized for web. Of course it isn't; it is for use in desktop applications.
|
|
|
|
|
so is there a way of doing it efficiently on web [printing bytes directly to printer]
|
|
|
|
|
Not directly. What you would have to do is implement an addon for the web browser and control the printing from that (oh, and you'd have to take into account the OS that the website was browsing as well). This isn't a trivial task, and a lot of organisations would bar this control from being installed.
|
|
|
|
|
You can't do it using that code. It's that simple.
That code is written to launch the application that knows how to edit the file and then tells that application to print the file that is passed to it.
This technique will NOT work with an array of bytes because you have no way of getting those bytes to the application that will actually handle the printing operation.
You cannot do what you want and most certainly can't do it from ASP.NET code running on the server.
|
|
|
|
|
Hi
please need urgent help , i am try to resart windows services , using a dropdownlist to choose the particular service, each time i choose the particular service and click restart button i get the error : (Particular service stopped)
public partial class Homepage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillServiceName();
}
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//Label1.Text = DropDownList1.SelectedIndex.ToString();
//Label1.Text = DropDownList1.SelectedIndex.ToString();
}
public void ServiceRestart(string nameofservice)
{
//Get the name of the service from the Web.config
// string nameofservice = ConfigurationManager.AppSettings["service1"];
ServiceController sv = new ServiceController(nameofservice);
//Get service timeout from App.Config file
int timeinmilliseconds = int.Parse(ConfigurationManager.AppSettings["timeinmilliseconds"].ToString());
try
{
if (sv.Status.Equals(ServiceControllerStatus.Running) && sv.CanStop)
{
int ms1 = Environment.TickCount;
int ms2;
TimeSpan timeout = TimeSpan.FromMilliseconds(timeinmilliseconds);
try
{
sv.Stop();
sv.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
//Console.WriteLine("Service " + nameofservice + " stopped");
Label2.Text = "Services " + nameofservice + " stopped";
ms2 = Environment.TickCount;
timeout = TimeSpan.FromMilliseconds(timeinmilliseconds - (ms2 - ms1));
}
catch
{
Label2.Text = "Services " + nameofservice + "failed to stoped";
}
try
{
sv.Start();
Label2.Text = "Services" + nameofservice + "started";
}
catch
{
Label2.Text = "Services" + nameofservice + "failed to start";
}
sv.WaitForStatus(ServiceControllerStatus.Running, timeout);
//Console.WriteLine("Service " + nameofservice + " started");
//Label2.Text="Services" + nameofservice + "started";
}
else
{
sv.Start();
//Console.WriteLine("Service " + nameofservice + " started");
Label2.Text = "Services" + nameofservice + "started";
}
}
catch (Exception e)
{
//Console.WriteLine("An error has occured: " + e.StackTrace);
//Label2.Text = "Services" + nameofservice + "stopped";
Label2.Text = "An error has occured: " + e.Message;
//Re-start the service but with a longer timeout period
//ServiceRestartAgain(nameofservice);
}
}
//Another service
public void ServiceRestartAgain(string nameofservice1)
{
//Get the name of the service from the Web.config
//string nameofservice1 = ConfigurationManager.AppSettings["service1"];
ServiceController sv1 = new ServiceController(nameofservice1);
int timeinmilliseconds1 = int.Parse(ConfigurationManager.AppSettings["timeinmilliseconds2"].ToString());
try
{
if (sv1.Status.Equals(ServiceControllerStatus.Running) && sv1.CanStop)
{
int ms11 = Environment.TickCount;
TimeSpan timeout1 = TimeSpan.FromMilliseconds(timeinmilliseconds1);
sv1.Stop();
sv1.WaitForStatus(ServiceControllerStatus.Stopped, timeout1);
//Console.WriteLine("Service " + nameofservice1 + " stopped");
Label2.Text="Service " + nameofservice1 + "stopped";
int ms22 = Environment.TickCount;
timeout1 = TimeSpan.FromMilliseconds(timeinmilliseconds1 - (ms22 - ms11));
sv1.Start();
sv1.WaitForStatus(ServiceControllerStatus.Running, timeout1);
//Console.WriteLine("Service " + nameofservice1 + " started");
Label2.Text="Service " + nameofservice1 + "started";
}
else
{
sv1.Start();
//Console.WriteLine("Service " + nameofservice1 + " started");
Label2.Text = "Service " + nameofservice1 + " started";
}
}
catch (Exception e)
{
string stacktrace = e.StackTrace;
//Console.WriteLine("An error has occured in restarting the service again: " + stacktrace);
Label2.Text = e.Message;
//Send mail to e-channels support(In the body of the mail put the stacktrace after adding the message. This is for tracking purposes.
// MailEChannelsSupport(stacktrace);
}
}
public void FillServiceName()
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ATMrestartserviceConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM Service", con);
cmd.ExecuteNonQuery();
SqlDataAdapter adap = new SqlDataAdapter(cmd);
DataSet dats = new DataSet();
adap.Fill(dats);
DataTable dt = new DataTable();
dt = dats.Tables[0];
ListItem lstitem = new ListItem();
lstitem = new ListItem();
lstitem.Text = "Select Service";
lstitem.Value = "s";
drpservice.Items.Add(lstitem);
foreach (DataRow datR in dt.Rows)
{
lstitem = new ListItem();
lstitem.Text = datR["Service"].ToString();
lstitem.Value = datR["Service"].ToString();
drpservice.Items.Add(lstitem);
}
con.Close();
}//end try
catch (Exception ex)
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = (string)Session["Uname"];
name=name.Replace(".", " ");
name=name.ToUpper();
ServiceRestart(drpservice.SelectedValue.ToString());
//string connectionString = "";
string connectionString = "Data Source=172.27.4.227;Initial Catalog=ATMrestartservice;User ID=sa;Password=Wema123";
//string connectionString = "Data Source=172.27.4.227;Initial Catalog=ATMrestartservice;User ID=sa";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT INTO Details ([Login Name],Date,[Service started]) VALUES ('" + name + "' ,'" + DateTime.Now + "', '" + drpservice.Text + "')";
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();
}
}
}
}
|
|
|
|
|
I hope that's not your real sa password that you've just published on a public forum!
Also, applications should NEVER connect using the sa user. You should always create and use a specific user which only has the permissions required by your application.
Your code in Button1_Click is susceptible to SQL Injection[^]. You should be using parameterized queries instead.
Most of the code you've posted doesn't appear to have anything to do with the problem your having. It's also not particularly easy to read, because you haven't formatted it - either use the "code" button on the toolbar, or wrap the code in <pre>...</pre> tags.
And finally, unless you've modified your AppPool to run as a user with local administrator privileges - which would be a very bad idea! - it won't have permission to restart services.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hai All,
I am facing one problem in my website i am having one default.aspx page its not inheriting master page what i need when i open my site it will expire after 6mins for me whats happening for every pages its working fine every page is inheriting master page but this default.aspx is not inheriting master page so when i open default.aspx and doing something also its showing time out.so now i want to stop master page session time in this defult.aspx how to do.here i dont want to inherit master page and recreate bcz if i inherit master page so many issues will come so other than any solution is there plz tel me its urgent
|
|
|
|
|
Member 10641698 wrote: plz tel me its urgent No. Find some consultants whom you will have to pay for such premium services.
|
|
|
|
|
Member 10641698 wrote: plz tel me its urgent
It's urgent.
Don't mind those people who say you're not HOT. At least you know you're COOL.
I'm not afraid of falling, I'm afraid of the sudden stop at the end of the fall! - Richard Andrew x64
|
|
|
|
|
You really understand the system.
|
|
|
|
|
|
There isn't enough information here for anyone to help.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi.
I have an application consists of 2 textboxes, 2 buttons, a modalpopup extender.
Button1 and Textbox1 is in a modalpopupextender that is shown when a button is click (not shown here)
I added an OnKeyPress event on my textbox (Textbox1) on Page Load that will execute a javascript on client side code which calls a button (Button1) click event.]
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.TextBox1.Attributes.Add("onKeyPress", "doClick('" + Button1.ClientID + "',event)");
}
}
This is the Javascript codes, this will call and execute the click event of Button1
function doClick(buttonName, e) {
var key;
if (window.event)
key = window.event.keyCode;
else
key = e.which;
if (key == 13) {
var btn = document.getElementById(buttonName);
if (btn != null) {
btn.click();
event.keyCode = 0
}
}
};
This is the Button1 Click event
protected void Button1_Click(object sender, EventArgs e)
{
if (Textbox1.Text.ToString() == "ITDevt")
{
Button2.Visible = true;
Textbox2.Visible = false;
Button2.Visible=true;
Button1.Visible=false;
popup.Show();
}
else
{
popup.Hide();
Textbox1.Text = "";
}
}
Assume that the modalpopupextender is shown, so I entered a text in Textbox1 and presses Enter key on keyboard (so the OnKeyPress event is rendered).
When I trace the Button1_Click event, the code block runs. But the popup (modalpopupextender) hides.
Can you help me show again the modalpopupextender and hide Button1 and Textbox1 then show Button2 and Textbox2?
|
|
|
|
|
Ask this in the ASP.NET forum. What you're asking has nothing to do with C#.
|
|
|
|
|
I noticed in one of my professor's MVC Java programming projects he put a Controller class inside a model package.
Is it true that in MVC often people use just MV and don't bother with the C because they don't think it's worth creating another layer just for a couple of extra classes?
It seemed illogical to me to put a controller inside a model package.
|
|
|
|
|
CsTreval wrote: Java
What has this got to do with C#?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My mistake. I thought I was on the 'General Questions' forum.
|
|
|
|
|
CsTreval wrote: Is it true that in MVC often people use just MV Maybe yes, maybe no; but this is not the place for such a question.
|
|
|
|
|
Greetings
I'm using InstallShield for deploying projects and I'm new in using it
I need to know how to include some applications and executable files to be installed while installing my application what I mean is that I need to include for example the .NET framework 4.0 so if it does not exist at the client it is installed during the installion of my application as well as the SQL Server Express edition.
Finally as the big picture of what I want to do is like making a setup project that is when installed it installs with it other applications needed by my application like .NET Framework and SQL Server for the database as well as attaching the database to the SQL Server instance. So when the client starts to setup my application when finished it uses the application without the need to setup other application or attaching the database to the SQL Server
|
|
|
|
|
You should not include SQL Server in your installation. There are a couple of reasons:
0) You can only distribute SQL Server Express for copyright reasons - not SQL Server full version.
1) They may already have SQL Server installed on the network. If so, then they will presumably want to use that version.
2) If they do have SQL server installed and you start proliferating SQL server Express instances, you are going to annoy the heck out of the database administrator...
3) A single site installation of SQl Server is a lot more likely to be backed up than a number of scattered version under user control.
4) Sql server is quite complex for a "normal" user to install and administer - it is not a good idea!
5) It will destroy the primary advantage of using Sql Server over SqlCE or SQLite - multiuser access. If everyone installs their own copy of SQL server, then you will have multiple copies of your database, each used by a single person. This will cause some confusion, and (depending on how you wrote the original database) may take some considerable effort to combine into a single instance when the problem is realized.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
What is the client does not have a SQL Server on his machine and the application require the database so he will have to install a SQL Server on his machine then he will have to attach the database himself. I need to make a single setup file as the software you buy e.g Microsoft Dynamics you do not have to install a separate SQL Server and to attach the database yourself. However, you give me a hint to query if there is an instance of SQL Server on the client machine if there is no instance I need only to setup the express edition to make the program running
|
|
|
|
|
SQL Server is a complicated beastie, and it really isn't that simple to install and administer: it's very easy to get it wrong and c**k the whole thing up. And most users aren't aware of it's existence in their LAN environment.
So ask yourself this: "Do I need SQL Server?"
Or would you be better off using a single user database which requires no installation, administration or maintenance? Because if you aren't using the multi-user facilities of SQL Server, then you are using a sledgehammer to crack a nut.
And if you do, then you need to ensure that someone competent installs and maintains it because otherwise you are going to give your users horrible problems down the line...
Seriously: don't install it for them.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|