Beispiel #1
0
        private bool ExecuteTest()
        {
            this.errorMsgs = new System.Collections.Generic.List <string>();
            System.Data.Common.DbTransaction dbTransaction = null;
            System.Data.Common.DbConnection  dbConnection  = null;
            string item;

            try
            {
                if (this.ValidateConnectionStrings(out item))
                {
                    System.Data.Common.DbConnection dbConnection2;
                    dbConnection = (dbConnection2 = new System.Data.SqlClient.SqlConnection(this.GetConnectionString()));
                    try
                    {
                        dbConnection.Open();
                        System.Data.Common.DbCommand dbCommand = dbConnection.CreateCommand();
                        dbTransaction         = dbConnection.BeginTransaction();
                        dbCommand.Connection  = dbConnection;
                        dbCommand.Transaction = dbTransaction;
                        dbCommand.CommandText = "CREATE TABLE installTest(Test bit NULL)";
                        dbCommand.ExecuteNonQuery();
                        dbCommand.CommandText = "DROP TABLE installTest";
                        dbCommand.ExecuteNonQuery();
                        dbTransaction.Commit();
                        dbConnection.Close();
                        goto IL_94;
                    }
                    finally
                    {
                        if (dbConnection2 != null)
                        {
                            ((System.IDisposable)dbConnection2).Dispose();
                        }
                    }
                }
                this.errorMsgs.Add(item);
                IL_94 :;
            }
            catch (System.Exception ex)
            {
                this.errorMsgs.Add(ex.Message);
                if (dbTransaction != null)
                {
                    try
                    {
                        dbTransaction.Rollback();
                    }
                    catch (System.Exception ex2)
                    {
                        this.errorMsgs.Add(ex2.Message);
                    }
                }
                if (dbConnection != null && dbConnection.State != System.Data.ConnectionState.Closed)
                {
                    dbConnection.Close();
                    dbConnection.Dispose();
                }
            }
            string folderPath = base.Request.MapPath(Globals.ApplicationPath + "/config/test.txt");

            if (!Install.TestFolder(folderPath, out item))
            {
                this.errorMsgs.Add(item);
            }
            try
            {
                Configuration configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath);
                if (configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString == "none")
                {
                    configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString = "required";
                }
                else
                {
                    configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString = "none";
                }
                configuration.Save();
            }
            catch (System.Exception ex3)
            {
                this.errorMsgs.Add(ex3.Message);
            }
            folderPath = base.Request.MapPath(Globals.ApplicationPath + "/storage/test.txt");
            if (!Install.TestFolder(folderPath, out item))
            {
                this.errorMsgs.Add(item);
            }
            return(this.errorMsgs.Count == 0);
        }
Beispiel #2
0
        private bool ExecuteTest()
        {
            this.errorMsgs = new List <string>();
            DbTransaction dbTransaction = null;
            DbConnection  dbConnection  = null;
            string        item          = default(string);

            try
            {
                if (this.ValidateConnectionStrings(out item))
                {
                    using (dbConnection = new SqlConnection(this.GetConnectionString()))
                    {
                        try
                        {
                            dbConnection.Open();
                            DbCommand dbCommand = dbConnection.CreateCommand();
                            dbTransaction         = dbConnection.BeginTransaction();
                            dbCommand.Connection  = dbConnection;
                            dbCommand.Transaction = dbTransaction;
                            dbCommand.CommandText = "CREATE TABLE installTest(Test bit NULL)";
                            dbCommand.ExecuteNonQuery();
                            dbCommand.CommandText = "DROP TABLE installTest";
                            dbCommand.ExecuteNonQuery();
                            dbTransaction.Commit();
                            dbConnection.Close();
                        }
                        catch (Exception ex)
                        {
                            this.errorMsgs.Add(ex.Message);
                        }
                    }
                }
                else
                {
                    this.errorMsgs.Add(item);
                }
            }
            catch (Exception ex2)
            {
                this.errorMsgs.Add(ex2.Message);
                if (dbTransaction != null)
                {
                    try
                    {
                        dbTransaction.Rollback();
                    }
                    catch (Exception ex3)
                    {
                        this.errorMsgs.Add(ex3.Message);
                    }
                }
                if (dbConnection != null && dbConnection.State != 0)
                {
                    dbConnection.Close();
                    dbConnection.Dispose();
                }
            }
            string folderPath = base.Request.MapPath("/config/test.txt");

            if (!Install.TestFolder(folderPath, out item))
            {
                this.errorMsgs.Add(item);
            }
            try
            {
                Configuration configuration = WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath);
                if (configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString == "none")
                {
                    configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString = "required";
                }
                else
                {
                    configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString = "none";
                }
                configuration.Save();
            }
            catch (Exception ex4)
            {
                this.errorMsgs.Add(ex4.Message);
            }
            folderPath = base.Request.MapPath("/storage/test.txt");
            if (!Install.TestFolder(folderPath, out item))
            {
                this.errorMsgs.Add(item);
            }
            foreach (string errorMsg in this.errorMsgs)
            {
                HttpContext.Current.Response.Write(errorMsg);
            }
            HttpContext.Current.Response.Write(this.errorMsgs.Count.ToString());
            return(this.errorMsgs.Count == 0);
        }