Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["USER"] == null)
        {
            Response.Redirect("Authorize.aspx");
        }


        string         filePath   = null;
        HttpPostedFile postedFile = Request.Files["rtnFile"];

        if (postedFile != null && postedFile.ContentLength > 0)
        {
            //Save the File.
            //   string filePath = Server.MapPath(uploaddir) + Path.GetFileName(postedFile.FileName);
            filePath = postedFile.FileName;
        }


        StreamReader StrWer;

        try
        {
            StrWer = File.OpenText(filePath);
            while (!(StrWer.EndOfStream))
            {
                this.lblText.Text = this.lblText.Text + StrWer.ReadLine() + "<br>";
            }
            StrWer.Close();
        }
        catch (Exception ex)
        {
            this.lblText.Text = "Read failed. (" + ex.Message + ")";
        }
    }
Ejemplo n.º 2
0
    public bool DoctorScheduleSyncer()
    {
        #region Variable
        clsSQL   clsSQL   = new clsSQL();
        FileInfo fi       = new FileInfo(System.Web.HttpContext.Current.Server.MapPath("/Upload/Doctor/SQLQuery.txt"));
        string   sqlQuery = "";
        bool     result   = false;
        #endregion

        if (fi.Exists)
        {
            StreamReader StrWer;
            try
            {
                StrWer = File.OpenText(System.Web.HttpContext.Current.Server.MapPath("/Upload/Doctor/SQLQuery.txt"));
                while (!(StrWer.EndOfStream))
                {
                    sqlQuery = sqlQuery + StrWer.ReadLine();
                }
                StrWer.Close();
            }
            catch (Exception) { }

            if (sqlQuery != "")
            {
                clsMail clsMail = new clsMail();
                string  outMail = ""; string outSQLError = "";
                if (!clsSQL.Execute(sqlQuery, dbType, cs, out outSQLError))
                {
                    clsMail.Send("*****@*****.**", "*****@*****.**",
                                 "DoctorScheduleSyncer : Error Insert (OnWeb)",
                                 outSQLError + "<hr/>" + sqlQuery, out outMail);
                    //lblDoctorScheduleSyncer.Text = "DoctorScheduleSyncer : เกิดข้อผิดพลาดขณะรันคำสั่ง<br/>"+sqlQuery;
                    fi.Delete();
                }
                else
                {
                    fi.Delete();
                    result = true;
                }
            }
        }
        else
        {
            result = true;
        }

        return(result);
    }