public string DefaultPrinterName() { string functionReturnValue = null; //System.Drawing.Printing.PrinterSettings oPS = new System.Drawing.Printing.PrinterSettings(); //foreach (string strPrinter in PrinterSettings.InstalledPrinters) //{ // // Show the name of the printer // MessageBox.Show(strPrinter); //} PrintDocument oPS = new PrintDocument(); //string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName; try { functionReturnValue = oPS.PrinterSettings.PrinterName; ESysLib.WriteLogError("Printer:" + oPS.PrinterSettings.PrinterName); } catch (System.Exception ex) { ESysLib.WriteLogError(ex.Message + "\n" + ex.StackTrace); } finally { oPS = null; } return(functionReturnValue); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string sqlText = ""; try { string img_pk = Request.QueryString["img_pk"]; string table_name = Request.QueryString["table_name"]; //string dbuser = Session["APP_DBUSER"].ToString(); string dbuser = "******"; string dbpass = Session["APP_DBPASS"].ToString(); if (img_pk == null || img_pk == "" || img_pk == "0") { img_pk = "-1";//show default image } sqlText = "select * from " + dbuser + "." + table_name + " where pk =" + img_pk; ESysLib.WriteLogFile(sqlText); string conString = ConfigurationManager.AppSettings["strConn"]; conString += "User Id=" + dbuser + ";password="******"CONTENTTYPE"].ToString(); Response.BinaryWrite((byte[])dr["DATA"]); } connection.Close(); } catch (Exception ex) { ESysLib.WriteLogError(ex.Message + ". " + sqlText); throw (ex); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string userID, userPass = ""; userID = Request.QueryString["userid"]; try { string queryString = "select esys.sf_get_pwd_by_userid('" + userID + "') xxx from dual"; string conString = ConfigurationManager.AppSettings["strConn"]; conString += "User id=esys;Password=esys2"; OracleConnection connection = new OracleConnection(conString); connection.Open(); OracleCommand command = new OracleCommand(queryString, connection); OracleDataReader reader; reader = command.ExecuteReader(); while (reader.Read()) { userPass = reader["xxx"].ToString(); } reader.Close(); connection.Close(); if (userPass == "" || userPass == null) { Response.Redirect(Application["rooturl"] + "/login.aspx?errmsg=Invalid user id or password."); } else { CheckLogin(userID, userPass); } } catch (Exception ex) { if (ex.Message.IndexOf("Thread was being aborted", 0, ex.Message.Length - 1) == -1) { ESysLib.WriteLogError(Server.MachineName + "\n" + ex.Message + "\n" + ex.StackTrace); Response.Redirect(Application["rooturl"] + "/login.aspx?errmsg=Invalid user id or password."); } } } }
private void CheckLogin(string p_user_id, string p_user_pass) { string user_info = ""; string[] parameter; string[] CDelimeter = new string[] { "|!" }; try { string queryString = "select esys.sf_check_login('" + p_user_id + "','" + p_user_pass + "') xxx, esys.sf_get_user_info('" + p_user_id + "') info from dual"; int rtnValue = -1; string conString = ConfigurationManager.AppSettings["strConn"]; conString += "User id=esys;Password=esys2"; OracleConnection connection = new OracleConnection(conString); connection.Open(); OracleCommand command = new OracleCommand(queryString, connection); OracleDataReader reader; reader = command.ExecuteReader(); while (reader.Read()) { rtnValue = Convert.ToInt16(reader["xxx"]); user_info = reader["info"].ToString(); } reader.Close(); if (rtnValue > 0 && p_user_id != "" && p_user_id != null) { if (user_info == "no_data_found") { Response.Redirect(Application["rooturl"] + "/login.aspx?errmsg=You have no permision to login the system."); } parameter = user_info.Split(CDelimeter, System.StringSplitOptions.None); Session["User_ID"] = p_user_id.ToLower(); Session["LOGIN_ID"] = p_user_id.ToLower(); Session["USER_PK"] = rtnValue; Session["ORG_PK"] = parameter[6]; Session["ORG_NAME"] = parameter[2]; Session["DEPT_PK"] = parameter[6]; Session["DEPT_NAME"] = parameter[2]; Session["ROLE_NAME"] = parameter[3]; Session["CODEADMIN_YN"] = parameter[4]; Session["Debug_YN"] = parameter[4]; Session["USER_NAME"] = parameter[0]; Session["EMPLOYEE_PK"] = parameter[1]; Session["COMPANY_PK"] = parameter[5]; Session["HR_LEVEL"] = parameter[7]; Session["SESSION_LANG"] = parameter[8]; Session["EMP_ID"] = parameter[9]; Session["POSITION_NAME"] = parameter[10]; Session["ANNOUNCE_YN"] = parameter[11]; command = new OracleCommand(); command.Connection = connection; command.CommandText = "esys.sp_login_entry"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("p_user_id", OracleType.VarChar, 20).Value = p_user_id; command.Parameters.Add("p_login_ip", OracleType.VarChar, 50).Value = Request.UserHostAddress; command.Parameters.Add("p_login_pcname", OracleType.VarChar, 50).Value = Request.UserHostName; command.ExecuteNonQuery(); connection.Close(); connection.Dispose(); Response.Redirect(Application["rooturl"] + "/system/Main.aspx"); } else { connection.Close(); connection.Dispose(); Response.Redirect(Application["rooturl"] + "/login.aspx?errmsg=Invalid user id or password."); } } catch (Exception ex) { if (ex.Message.IndexOf("Thread was being aborted", 0, ex.Message.Length - 1) == -1) { ESysLib.WriteLogError(ex.Message + "\n" + ex.StackTrace); Response.Redirect(Application["rooturl"] + "/login.aspx?errmsg=System meet error. Please check log file to know the reason."); } } }
private void CreateImage(string function) { string rtnValue = ""; try { string _dbuser = function.Substring(0, function.IndexOf(".", 0)); string conString = ConfigurationManager.AppSettings["strConn"]; conString += "User Id=" + _dbuser + ";Password="******"2"; OracleConnection con = new OracleConnection(conString); con.Open(); string queryString = "select " + function + " xxx from dual"; OracleCommand command = new OracleCommand(queryString, con); OracleDataReader reader; reader = command.ExecuteReader(); while (reader.Read()) { rtnValue = Convert.ToString(reader["xxx"]); } reader.Close(); con.Close(); } catch (Exception ex) { ESysLib.WriteLogError(ex.Message + "\n" + ex.StackTrace); return; } if (rtnValue == "") { return; } Bitmap objBitmap; Graphics objGraphics = null; int ActualRows = 0; int ActualCols = 0; int ActualWidth = 0; int ActualHeight = 0; int ExtraWidth, ExtraHeight; Point p; Response.ContentType = "image/gif"; PDF417Net MyPDF417 = new PDF417Net(); MyPDF417.BackColor = Color.FromName("White"); MyPDF417.BarColor = Color.FromName("Black"); MyPDF417.Data = rtnValue; // "12321984912\n3ry8sdjhfv\nsdj sdjsd \nds v sdhsdjvsjd\njdsjsdahjsd sdav csaj sjd jhv\nahsdv chjw";//Request.QueryString["Data"]; //MyPDF417.ErrorCorrectionLevel = 2; //0->8 MyPDF417.Mode = 0; //0:Binary, 1:Text, 2:Auto //MyPDF417.NarrowBarWidth = 0.07;//(float)System.Convert.ToDouble(Request.QueryString["NarrowBarWidth"]); MyPDF417.Orientation = 0; //0: 0 degree, 1: 90 degree, 2: 180 degree, 3: 270 degree MyPDF417.Columns = 4; //1->30 MyPDF417.Rows = 3; //1->90 MyPDF417.TruncateSymbol = false; //(Request.QueryString["TruncateSymbol"] == "ON"); MyPDF417.HandleTilde = false; // (Request.QueryString["HandleTilde"] == "ON"); //MyPDF417.Y2XRatio = 3.0;//(float)System.Convert.ToDouble(Request.QueryString["Y2XRatio"]); //// Get actual rows and columns of PDF417 barcode MyPDF417.GetActualRC(ref ActualRows, ref ActualCols); //// Get actual barcode width and height MyPDF417.GetActualSize(ref ActualWidth, ref ActualHeight); ExtraWidth = 30; //System.Convert.ToInt16(Request.QueryString["ExtraWidth"]); ExtraHeight = 40; //System.Convert.ToInt16(Request.QueryString["ExtraHeight"]); // Image size = barcode size + extra space //if (MyPDF417.Orientation == 0 || MyPDF417.Orientation == 2) //{ // MyPDF417.SetSize(ActualWidth + ExtraWidth, ActualHeight + ExtraHeight); // objBitmap = new Bitmap(ActualWidth + ExtraWidth, ActualHeight + ExtraHeight); //} //else //{ // MyPDF417.SetSize(ActualHeight + ExtraWidth, ActualWidth + ExtraHeight); // objBitmap = new Bitmap(ActualHeight + ExtraWidth, ActualWidth + ExtraHeight); //} MyPDF417.SetSize(ActualWidth + ExtraWidth, ActualHeight + ExtraHeight); objBitmap = new Bitmap(ActualWidth + ExtraWidth, ActualHeight + ExtraHeight); objGraphics = Graphics.FromImage(objBitmap); p = new Point(0, 0); MyPDF417.Render(objGraphics, p); objBitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); objGraphics.Flush(); }