Exemple #1
0
    public void Save()
    {
        LastLog = this;

        XmlDocument document   = new XmlDocument();
        string      strLogFile = LogFile();

        document.Load(strLogFile);
        XmlNode node = document.SelectSingleNode("Logs");

        XmlNode newNode = NewElement(document, "Event", null, null);

        NewAttribute(document, newNode, "LogID", this.LogID.ToString());
        NewAttribute(document, newNode, "LogType", this.LogType.ToString());
        NewAttribute(document, newNode, "RawUrl", this.RawUrl);
        NewAttribute(document, newNode, "Url", this.Url);
        NewAttribute(document, newNode, "UserID", this.UserID.ToString());
        NewAttribute(document, newNode, "CreateDate", String.Format("{0:s}", this.CreateDate));

        NewElement(document, "Message", this.Message, newNode);
        NewElement(document, "Source", this.Source, newNode);
        NewElement(document, "StackTrace", this.StackTrace, newNode);
        NewElement(document, "TargetSite", this.TargetSite.ToString(), newNode);

        node.PrependChild(newNode);

        document.Save(strLogFile);
    }
Exemple #2
0
    protected void btnInstall_Click(object sender, EventArgs e)
    {
        string ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\{0}.mdb;",
                txtDatabaseName.Text);
        OleDbConnection OConn = new OleDbConnection(ConnectionString);
        StreamReader Sr = new StreamReader(Server.MapPath("~/Setup/Scripts/Access.sql"));
        try
        {
            File.Copy(Server.MapPath("~/Setup/Scripts/Blogsa.mdb"), Server.MapPath(string.Format("~/App_Data/{0}.mdb", txtDatabaseName.Text)));

            //Update WebSite Url
            string strUrl = Request.Url.AbsoluteUri.Substring(0
                , Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath) + (Request.ApplicationPath.Equals("/") ? 0 : Request.ApplicationPath.Length)) + "/";

            OConn.Open();
            while (!Sr.EndOfStream)
            {
                //Create DB
                string Commands = Sr.ReadLine().ToString();
                if (!Commands.StartsWith("/*"))
                {
                    OleDbCommand OComm = new OleDbCommand(Commands, OConn);
                    OComm.ExecuteNonQuery();
                    OComm.Dispose();
                }
            }

            Sr.Close();
            string strLang = (string)Session["lang"];
            string strRedirectPage = String.Format("Completed.aspx?Setup={0}&lang={1}", BSHelper.SaveWebConfig(ConnectionString, "System.Data.OleDb"), strLang);
            Response.Redirect(strRedirectPage, false);
        }
        catch (Exception ex)
        {
            BSLog l = new BSLog();
            l.CreateDate = DateTime.Now;
            l.LogType = BSLogType.Error;
            l.LogID = Guid.NewGuid();
            l.RawUrl = Request.RawUrl;
            l.Source = ex.Source;
            l.StackTrace = ex.StackTrace;
            l.TargetSite = ex.TargetSite;
            l.Url = Request.Url.ToString();
            l.Save();

            divError.Visible = true;
            lblError.Text = ex.Message;
            if (OConn.State == ConnectionState.Open)
            {
                OConn.Close();
            }
            File.Delete(Server.MapPath("~/App_Data/" + txtDatabaseName.Text));
        }
        finally
        {
            if (OConn.State == ConnectionState.Open)
                OConn.Close();
            Sr.Close();
        }
    }
Exemple #3
0
 /// <summary>
 /// If return value status type is Error then write log.
 /// </summary>
 /// <param name="returnValue"></param>
 private void WriteLog(DataReturnValue returnValue)
 {
     if (returnValue.Status == DataProcessState.Error)
     {
         BSLog l = new BSLog();
         l.CreateDate = DateTime.Now;
         l.LogID      = Guid.NewGuid();
         l.LogType    = BSLogType.Error;
         l.Message    = returnValue.Error.Message;
         l.RawUrl     = HttpContext.Current.Request.RawUrl;
         l.Source     = returnValue.Error.Source;
         l.StackTrace = returnValue.Error.StackTrace;
         l.TargetSite = returnValue.Error.TargetSite;
         l.Url        = HttpContext.Current.Request.Url.ToString();
         l.UserID     = Blogsa.ActiveUser != null ? Blogsa.ActiveUser.UserID : 0;
         l.Save();
     }
 }
    protected void btnInstall_Click(object sender, EventArgs e)
    {
        string ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\{0}.mdb;",
                                                txtDatabaseName.Text);
        OleDbConnection OConn = new OleDbConnection(ConnectionString);
        StreamReader    Sr    = new StreamReader(Server.MapPath("~/Setup/Scripts/Access.sql"));

        try
        {
            File.Copy(Server.MapPath("~/Setup/Scripts/Blogsa.mdb"), Server.MapPath(string.Format("~/App_Data/{0}.mdb", txtDatabaseName.Text)));

            //Update WebSite Url
            string strUrl = Request.Url.AbsoluteUri.Substring(0
                                                              , Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath) + (Request.ApplicationPath.Equals("/") ? 0 : Request.ApplicationPath.Length)) + "/";


            OConn.Open();
            while (!Sr.EndOfStream)
            {
                //Create DB
                string Commands = Sr.ReadLine().ToString();
                if (!Commands.StartsWith("/*"))
                {
                    OleDbCommand OComm = new OleDbCommand(Commands, OConn);
                    OComm.ExecuteNonQuery();
                    OComm.Dispose();
                }
            }

            Sr.Close();
            string strLang         = (string)Session["lang"];
            string strRedirectPage = String.Format("Completed.aspx?Setup={0}&lang={1}", BSHelper.SaveWebConfig(ConnectionString, "System.Data.OleDb"), strLang);
            Response.Redirect(strRedirectPage, false);
        }
        catch (Exception ex)
        {
            BSLog l = new BSLog();
            l.CreateDate = DateTime.Now;
            l.LogType    = BSLogType.Error;
            l.LogID      = Guid.NewGuid();
            l.RawUrl     = Request.RawUrl;
            l.Source     = ex.Source;
            l.StackTrace = ex.StackTrace;
            l.TargetSite = ex.TargetSite;
            l.Url        = Request.Url.ToString();
            l.Save();

            divError.Visible = true;
            lblError.Text    = ex.Message;
            if (OConn.State == ConnectionState.Open)
            {
                OConn.Close();
            }
            File.Delete(Server.MapPath("~/App_Data/" + txtDatabaseName.Text));
        }
        finally
        {
            if (OConn.State == ConnectionState.Open)
            {
                OConn.Close();
            }
            Sr.Close();
        }
    }
Exemple #5
0
 /// <summary>
 /// If return value status type is Error then write log.
 /// </summary>
 /// <param name="returnValue"></param>
 private void WriteLog(DataReturnValue returnValue)
 {
     if (returnValue.Status == DataProcessState.Error)
     {
         BSLog l = new BSLog();
         l.CreateDate = DateTime.Now;
         l.LogID = Guid.NewGuid();
         l.LogType = BSLogType.Error;
         l.Message = returnValue.Error.Message;
         l.RawUrl = HttpContext.Current.Request.RawUrl;
         l.Source = returnValue.Error.Source;
         l.StackTrace = returnValue.Error.StackTrace;
         l.TargetSite = returnValue.Error.TargetSite;
         l.Url = HttpContext.Current.Request.Url.ToString();
         l.UserID = Blogsa.ActiveUser != null ? Blogsa.ActiveUser.UserID : 0;
         l.Save();
     }
 }