Exemple #1
0
        public static ActionResult DownloadSQLServer(Session session)
        {
            sessionObj = session;
            string type   = Environment.GetEnvironmentVariable(@"PROCESSOR_ARCHITECTURE");
            string sqlUrl = type.ToUpperInvariant().Contains("86")
                ? CustomActions.SqlServerX86Url
                : CustomActions.SqlServer64Url;

            DownloadEngine sqlEngine = new DownloadEngine(sqlUrl);

            sqlEngine.Log += (s) => {
                int pct = Convert.ToInt32((Convert.ToDouble(Int32.Parse(s)) / Convert.ToDouble(sqlEngine.TotalBytes)) * 100);
                CustomActions.LogToSession(string.Format("SqlServer: {0}", pct));
            };
            bool sqlDownloaded = sqlEngine.Download();

            if (!sqlDownloaded)
            {
                CustomActions.LogToSession("SqlServer Failed to download");
                return(ActionResult.Failure);
            }
            CustomActions.LogToSession(string.Format("File is: {0}", sqlEngine.DownloadedFile));
            session["SQLSERVERFILE"] = sqlEngine.DownloadedFile;

            return(ActionResult.Success);
        }
Exemple #2
0
        public static ActionResult InstallingSQLServer(Session session)
        {
            string sqlfile = session["SQLSERVERFILE"];

            if (!string.IsNullOrEmpty(sqlfile))
            {
                Process process = new Process();
                process.StartInfo.FileName               = sqlfile;
                process.StartInfo.Arguments              = @"";
                process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                process.StartInfo.ErrorDialog            = false;
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardError  = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => {
                    CustomActions.LogToSession(string.Format("[SqlServerInstall-Error] {0}", e.Data));
                };

                process.OutputDataReceived += (object sender, DataReceivedEventArgs e) => {
                    CustomActions.LogToSession(string.Format("[SqlServerInstall-Output] {0}", e.Data));
                };

                process.EnableRaisingEvents = true;
                process.Exited += (object sender, EventArgs e) => {
                    CustomActions.LogToSession(string.Format("[SqlServerInstall Exited with code {0}]", process.ExitCode));
                };
                process.Start();
                while (!process.HasExited)
                {
                    System.Threading.Thread.Sleep(new TimeSpan(0, 0, 2));
                }
            }
            return(ActionResult.Success);
        }
Exemple #3
0
        public XMLSettingsManager()
        {
            try
            {
                DataSet ds = new DataSet();

                ds.ReadXml(SettingsFile());

                DataRow dr = ds.Tables[0].Rows[0];

                SQLServerName    = ExtractField(dr, "SQLServerName");
                SQLInstanceName  = ExtractField(dr, "SQLInstanceName");
                DatabaseName     = ExtractField(dr, "DatabaseName");
                SAPassword       = ExtractField(dr, "SAPassword");
                OMLUserAcct      = ExtractField(dr, "OMLUserAcct");
                OMLUserPassword  = ExtractField(dr, "OMLUserPassword");
                ConfigFileExists = true;

                CustomActions.LogToSession("[SettingsManager] : Loaded settings xml");
            }
            catch (Exception ex)
            {
                CustomActions.LogToSession(string.Format("[SettingsManager] : Failed to load settings xml {0}", ex.Message));

                SQLServerName    = null;
                SQLInstanceName  = null;
                DatabaseName     = null;
                SAPassword       = null;
                OMLUserAcct      = null;
                OMLUserPassword  = null;
                ConfigFileExists = false;
            }
        }
Exemple #4
0
        public static ActionResult DownloadAndInstallMEncoder(Session session)
        {
            sessionObj = session;
            DownloadEngine meEngine = new DownloadEngine(CustomActions.MEncoderUrl);

            meEngine.Log += (s) => {
                int pct = Convert.ToInt32((Convert.ToDouble(Int32.Parse(s)) / Convert.ToDouble(meEngine.TotalBytes)) * 100);
                CustomActions.LogToSession(string.Format("MEncoder: {0}", pct));
            };
            bool meDownloaded = meEngine.Download();

            if (!meDownloaded)
            {
                CustomActions.LogToSession("MEncoder Failed to download");
                return(ActionResult.Failure);
            }
            CustomActions.LogToSession(string.Format("File is: {0}", meEngine.DownloadedFile));
            try {
                File.Copy(meEngine.DownloadedFile, CustomActions.MEncoderPath, true);
            } catch (Exception ex) {
                CustomActions.LogToSession(string.Format("MEncoder Error: {0}", ex.Message));
                return(ActionResult.Failure);
            }

            return(ActionResult.Success);
        }
Exemple #5
0
 public static ActionResult ActivateNetTcpPortSharing(Session session)
 {
     sessionObj = session;
     try {
         System.ServiceModel.Activation.Configuration.NetTcpSection ntSection = new System.ServiceModel.Activation.Configuration.NetTcpSection();
         ntSection.TeredoEnabled = true;
         CustomActions.LogToSession("ActivateNetTcpPortSharing: Success");
         return(ActionResult.Success);
     } catch (Exception e) {
         CustomActions.LogToSession(string.Format("Failed to activate NetTcpPortSharing: {0}", e.Message));
         return(ActionResult.Failure);
     }
 }
Exemple #6
0
        public static ActionResult DownloadAndInstallMediaInfo(Session session)
        {
            sessionObj = session;
            string type  = Environment.GetEnvironmentVariable(@"PROCESSOR_ARCHITECTURE");
            string miUrl = type.ToUpperInvariant().Contains("86")
                ? CustomActions.MediaInfoX86Url
                : CustomActions.MediaInfoX64Url;

            CustomActions.LogToSession(string.Format("MediaInfo: Selected {0} based on detected processor architecture of {1}",
                                                     miUrl, Environment.GetEnvironmentVariable(@"PROCESSOR_ARCHITECTURE")));

            DownloadEngine miEngine = new DownloadEngine(miUrl);

            miEngine.Bytes += (i) => {
                if (i > 0)
                {
                    int pct = Convert.ToInt32((Convert.ToDouble(i) / Convert.ToDouble(miEngine.TotalBytes)) * 100);
                    CustomActions.LogToSession(string.Format("MediaInfo: ({0}) {1}b of {2}b", pct, i, miEngine.TotalBytes));
                }
            };

            CustomActions.LogToSession("MediaInfo: Beginning download");
            bool miDownloaded = false;

            try {
                miDownloaded = miEngine.Download(true);
            } catch (Exception ex) {
                CustomActions.LogToSession(string.Format("MediaInfo: Error {0}", ex.Message));
                return(ActionResult.Failure);
            }

            if (!miDownloaded)
            {
                CustomActions.LogToSession("MediaInfo: Failed to download");
                return(ActionResult.Failure);
            }
            CustomActions.LogToSession(string.Format("MediaInfo: Downloaded File Location {0}", miEngine.DownloadedFile));
            CustomActions.LogToSession(string.Format("MediaInfo: Final destination is {0}", CustomActions.MediaInfoLocalPath));

            try {
                CustomActions.LogToSession("MediaInfo: copying into final location");
                File.Copy(miEngine.DownloadedFile, CustomActions.MediaInfoLocalPath, true);
            } catch (Exception ex) {
                CustomActions.LogToSession(string.Format("MediaInfo Error: {0}", ex.Message));
                return(ActionResult.Failure);
            }

            return(ActionResult.Success);
        }
Exemple #7
0
 public static ActionResult StartOMLFWService(Session session)
 {
     sessionObj = session;
     try {
         ServiceController omlfsserviceController = new ServiceController(@"OMLFWService");
         TimeSpan          timeout = TimeSpan.FromSeconds(10);
         omlfsserviceController.Start();
         omlfsserviceController.WaitForStatus(ServiceControllerStatus.Running, timeout);
         omlfsserviceController.Close();
     } catch (Exception e) {
         CustomActions.LogToSession(string.Format("An error occured starting the OMLFW Service: {0}", e.Message));
         return(ActionResult.Failure);
     }
     return(ActionResult.Success);
 }
Exemple #8
0
 public static ActionResult StartOMLEngineService(Session session)
 {
     sessionObj = session;
     CustomActions.LogToSession("Inside StartOMLEngineService");
     try {
         ServiceController omlengineController = new ServiceController(@"OMLEngineService");
         TimeSpan          timeout             = TimeSpan.FromSeconds(20);
         omlengineController.Start();
         omlengineController.WaitForStatus(ServiceControllerStatus.Running, timeout);
         omlengineController.Close();
         CustomActions.LogToSession("StartOMLEngineService CA: Success");
         return(ActionResult.Success);
     } catch (Exception e) {
         CustomActions.LogToSession(string.Format("Error starting OMLEngineService: {0}", e.Message));
         return(ActionResult.Failure);
     }
 }
Exemple #9
0
        public static ActionResult ScanNetworkForSqlServers(Session session)
        {
            sessionObj = session;
            if (xmlSettings == null)
            {
                xmlSettings = new XMLSettingsManager();
            }

            if ((session["HASSCANNEDFORSQL"].CompareTo("0") == 0) && (session["ISSERVERINSTALL"] != "0"))
            {
                if (xmlSettings.SettingsFileExists())
                {
                    return(ActionResult.SkipRemainingActions);
                }
                else
                {
                    DataTable dt          = SqlDataSourceEnumerator.Instance.GetDataSources();
                    View      sqlComboBox = session.Database.OpenView("SELECT * FROM `ComboBox`");
                    sqlComboBox.Execute();
                    int numRows = 0;
                    while (sqlComboBox.Fetch() != null)
                    {
                        numRows++;
                    }
                    if (numRows == 1)
                    {
                        CustomActions.LogToSession(string.Format("found {0} sql servers", dt.Rows.Count));
                        int itemNumber = 2;
                        foreach (DataRow row in dt.Rows)
                        {
                            Record rec = new Record(3);
                            rec.SetString(1, "OMLProp_SqlServers");
                            rec.SetInteger(2, itemNumber);
                            string description = string.Format("{0} - {1}", row["ServerName"], row["InstanceName"]);
                            rec.SetString(3, description);

                            CustomActions.LogToSession(string.Format("Adding a new record, its number will be {0} and its value will be {1}", itemNumber, string.Format("{0} ({1})", row["ServerName"], row["InstanceName"])));
                            sqlComboBox.Modify(ViewModifyMode.InsertTemporary, rec);
                            itemNumber++;
                        }
                    }
                }
                session["HASSCANNEDFORSQL"] = "1";
            }
            return(ActionResult.Success);
        }
Exemple #10
0
        /// <summary>
        /// Creates the OML user. This should allready have been done as part
        /// of the installer.
        /// </summary>
        private void CreateOMLUser(SqlConnection sqlConn)
        {
            CustomActions.LogToSession("[DatabaseManagement] : Entering CreateOMLUser()");

            ExecuteNonQuery(sqlConn, "CREATE LOGIN [" + DatabaseInformation.xmlSettings.OMLUserAcct + "] " +
                            "WITH PASSWORD=N'" + DatabaseInformation.xmlSettings.OMLUserPassword + "', " +
                            " DEFAULT_DATABASE=[" + DatabaseInformation.xmlSettings.DatabaseName + "], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF");

            sqlConn.ChangeDatabase(DatabaseInformation.xmlSettings.DatabaseName);
            ExecuteNonQuery(sqlConn, "DROP USER [" + DatabaseInformation.xmlSettings.OMLUserAcct + "]");
            ExecuteNonQuery(sqlConn, "DROP ROLE [" + DatabaseInformation.xmlSettings.OMLUserAcct + "]");
            ExecuteNonQuery(sqlConn, "CREATE USER [" + DatabaseInformation.xmlSettings.OMLUserAcct + "] FOR LOGIN [" + DatabaseInformation.xmlSettings.OMLUserAcct + "] WITH DEFAULT_SCHEMA=[dbo]");
            ExecuteNonQuery(sqlConn, "EXEC sp_addrolemember [db_owner], [" + DatabaseInformation.xmlSettings.OMLUserAcct + "]");
            sqlConn.ChangeDatabase("master");

            CustomActions.LogToSession("[DatabaseManagement] : Leaving CreateOMLUser()");
        }
Exemple #11
0
        private bool ExecuteScalar(SqlConnection sqlConn, string query, out object data)
        {
            data = null;
            SqlCommand sqlComm = new SqlCommand(query, sqlConn);

            try
            {
                data = sqlComm.ExecuteScalar();
            }
            catch (Exception ex)
            {
                CustomActions.LogToSession("[DatabaseManagement / ExecuteScalar()] : Executing SQL -" + query);
                CustomActions.LogToSession("                      Returned error - " + ex.Message);
                CustomActions.LogToSession("                      Connection string - " + sqlConn.ConnectionString);

                DatabaseInformation.LastSQLError = ex.Message;
                return(false);
            }
            return(true);
        }
Exemple #12
0
        public static ActionResult DownloadAndInstallUserManual(Session session)
        {
            sessionObj = session;
            DownloadEngine umEngine = new DownloadEngine(CustomActions.UserManualUrl);

            umEngine.Log += (s) => {
                int pct = Convert.ToInt32((Convert.ToDouble(Int32.Parse(s)) / Convert.ToDouble(umEngine.TotalBytes)) * 100);
                CustomActions.LogToSession(string.Format("PDF: {0}", pct));
            };
            bool umDownloaded = umEngine.Download();

            if (!umDownloaded)
            {
                CustomActions.LogToSession("Open_Media_Library_User_Manual Failed to download");
                return(ActionResult.Failure);
            }
            CustomActions.LogToSession(string.Format("File is: {0}", umEngine.DownloadedFile));
            try {
                if (Directory.Exists(CustomActions.UserManualHelpPath))
                {
                    CustomActions.LogToSession(string.Format(@"Creating folder: {0}", CustomActions.UserManualHelpPath));
                    Directory.CreateDirectory(CustomActions.UserManualHelpPath);
                    CustomActions.LogToSession("setting access controls");
                    //    DirectoryInfo dInfo = new DirectoryInfo(CustomActions.UserManualHelpPath);
                    //    System.Security.AccessControl.DirectorySecurity dSec = dInfo.GetAccessControl();
                    //    dSec.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(
                    //        "Users", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow
                    //        ));
                    //    dInfo.SetAccessControl(dSec);
                }
                CustomActions.LogToSession("Copying file");
                File.Copy(umEngine.DownloadedFile, CustomActions.UserManualPath, true);
            } catch (Exception ex) {
                CustomActions.LogToSession(string.Format("Open_Media_Library_User_Manual Error: {0}", ex.Message));
                return(ActionResult.Failure);
            }

            return(ActionResult.Success);
        }
Exemple #13
0
        public static ActionResult ReserveTrailersUrl(Session session)
        {
            sessionObj = session;
            CustomActions.LogToSession("Inside ReserveTrailersUrl");
            try {
                SecurityIdentifier sid;

                //add users in case someone runs the service as themselves
                sid = new SecurityIdentifier("S-1-5-32-545");//users
                URLReservation.UrlReservation rev = new URLReservation.UrlReservation("http://127.0.0.1:8484/3f0850a7-0fd7-4cbf-b8dc-c7f7ea31534e/");
                rev.AddSecurityIdentifier(sid);

                //add system because that is the default
                sid = new SecurityIdentifier("S-1-5-18");//system
                rev.AddSecurityIdentifier(sid);
                rev.Create();
                CustomActions.LogToSession("ReserveTrailersUrl CA: Success");
                return(ActionResult.Success);
            } catch (Exception e) {
                CustomActions.LogToSession(string.Format("Error in ReserveTrailersUrl: {0}", e.Message));
                return(ActionResult.Failure);
            }
        }
Exemple #14
0
        /// <summary>
        /// Performs a series of tests on the OML database to ensure there are no problems
        /// </summary>
        /// <returns></returns>
        private DatabaseInformation.SQLState CheckOMLDatabase()
        {
            CustomActions.LogToSession("[DatabaseManagement] : Entering CheckOMLDatabase()");

            // Test 1. Create database connection to OML and open it
            // -----------------------------------------------------
            SqlConnection sqlConn = OpenDatabase(DatabaseInformation.OMLDatabaseConnectionString);

            if (sqlConn == null)
            {
                CustomActions.LogToSession("[DatabaseManagement / CheckOMLDatabase()] : Failed to login using - " + DatabaseInformation.OMLDatabaseConnectionString);
                return(DatabaseInformation.SQLState.LoginFailure);
            }

            // Test 2. Ensure the database is in multiuser mode - could be a result of a bad restore
            // -------------------------------------------------------------------------------------
            string sql = "ALTER DATABASE [" + DatabaseInformation.xmlSettings.DatabaseName + "] SET MULTI_USER";

            if (!ExecuteNonQuery(sqlConn, sql))
            {
                CustomActions.LogToSession("[DatabaseManagement / CheckOMLDatabase()] : Attempting to set the database to Multi user failed");
                sqlConn.Close();
                sqlConn.Dispose();
                return(DatabaseInformation.SQLState.UnknownState);
            }

            // Test 3. Get the schema version number for later comparison
            // ----------------------------------------------------------
            // Schema versioning disabled for now
            int ReqMajor;
            int ReqMinor;
            int CurrentMajor;
            int CurrentMinor;

            DatabaseInformation.SQLState sqlstate = DatabaseInformation.SQLState.UnknownState;

            GetRequiredSchemaVersion(out ReqMajor, out ReqMinor);

            if (GetSchemaVersion(sqlConn, out CurrentMajor, out CurrentMinor))
            {
                if (ReqMajor > CurrentMajor)
                {
                    sqlstate = DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired;
                }
                if (ReqMajor < CurrentMajor)
                {
                    sqlstate = DatabaseInformation.SQLState.OMLDBVersionCodeOlderThanSchema;
                }

                if (ReqMajor == CurrentMajor)
                {
                    if (ReqMinor > CurrentMinor)
                    {
                        sqlstate = DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired;
                    }
                    if (ReqMinor < CurrentMinor)
                    {
                        sqlstate = DatabaseInformation.SQLState.OMLDBVersionCodeOlderThanSchema;
                    }
                    if (ReqMinor == CurrentMinor)
                    {
                        sqlstate = DatabaseInformation.SQLState.OK;
                    }
                }
            }
            else
            {
                // Cannot find schema version
                sqlstate = DatabaseInformation.SQLState.OMLDBVersionNotFound;
                CustomActions.LogToSession("[DatabaseManagement / CheckOMLDatabase()] : Unable to finr the schema version.");
            }


            sqlConn.Close();
            sqlConn.Dispose();

            CustomActions.LogToSession("[DatabaseManagement] : Leaving CheckOMLDatabase()");

            return(sqlstate);
        }
Exemple #15
0
        /// <summary>
        /// A problem has been found, performs a series of tests on the master database to identify problem
        /// </summary>
        /// <returns></returns>
        private DatabaseInformation.SQLState DatabaseDiagnostics()
        {
            CustomActions.LogToSession("[DatabaseManagement] : Entering DatabaseDiagnostics()");

            object data;

            // Test 1. Open database connection to Master and open it
            // ------------------------------------------------------
            CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Checking the master database");
            SqlConnection sqlConn = OpenDatabase(DatabaseInformation.MasterDatabaseConnectionString);

            if (sqlConn == null)
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Failed to login using - " + DatabaseInformation.MasterDatabaseConnectionString);
                return(DatabaseInformation.SQLState.LoginFailure);
            }

            // Test 2. Check if the database exists on the server
            CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Checking the oml sysdatabase entry");
            string sql = "select count(*) from sysdatabases where name = '" + DatabaseInformation.xmlSettings.DatabaseName + "'";

            if (!ExecuteScalar(sqlConn, sql, out data))
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : sysdatabases check failed");
                sqlConn.Close();
                sqlConn.Dispose();
                return(DatabaseInformation.SQLState.UnknownState);
            }

            if (Convert.ToInt32(data) != 1)
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Could not find the database - " + DatabaseInformation.xmlSettings.DatabaseName);
                sqlConn.Close();
                sqlConn.Dispose();
                return(DatabaseInformation.SQLState.OMLDBNotFound);
            }


            // Test 3. Check user account exists
            // ---------------------------------
            CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Checking the syslogins entry");
            sql = "select count(*) from syslogins where name = '" + DatabaseInformation.xmlSettings.OMLUserAcct.ToLower() + "'";
            if (!ExecuteScalar(sqlConn, sql, out data))
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : syslogins check failed");
                sqlConn.Close();
                sqlConn.Dispose();
                return(DatabaseInformation.SQLState.UnknownState);
            }

            if (Convert.ToInt32(data) != 1)
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Could not find the oml login in master database");
                // Try to create user
                CreateOMLUser(sqlConn);
                return(DatabaseInformation.SQLState.OMLUserNotFound);
            }

            // Test 4. Check user account exists in oml database
            // -------------------------------------------------
            sqlConn.ChangeDatabase(DatabaseInformation.xmlSettings.DatabaseName);
            CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Checking the oml.sysusers entry");
            sql = "select count(*) from sysusers where name = '" + DatabaseInformation.xmlSettings.OMLUserAcct.ToLower() + "'";
            if (!ExecuteScalar(sqlConn, sql, out data))
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : oml.sysusers check failed");

                sqlConn.Close();
                sqlConn.Dispose();
                return(DatabaseInformation.SQLState.UnknownState);
            }

            if (Convert.ToInt32(data) != 1)
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Could not find the oml user in the user database");
                // Try to create user
                CreateOMLUser(sqlConn);
                return(DatabaseInformation.SQLState.OMLUserNotFound);
            }

            // Test 5. Check for matching sid on the master.syslogins amd oml.sysusers entries
            // --------------------------------------------------------------------------------
            sqlConn.ChangeDatabase(DatabaseInformation.xmlSettings.DatabaseName);
            CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Checking the sid fields on master.sys oml.sysusers");
            sql = "select count(*) from master.sys.syslogins sl " +
                  "inner join oml.sys.sysusers su " +
                  "on sl.sid = su.sid " +
                  "where sl.name = '" + DatabaseInformation.xmlSettings.OMLUserAcct.ToLower() + "' " +
                  "and  su.name = '" + DatabaseInformation.xmlSettings.OMLUserAcct.ToLower() + "'";
            if (!ExecuteScalar(sqlConn, sql, out data))
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : sid fields on master.sys oml.sysusers check failed");

                sqlConn.Close();
                sqlConn.Dispose();
                return(DatabaseInformation.SQLState.UnknownState);
            }

            if (Convert.ToInt32(data) < 1)
            {
                CustomActions.LogToSession("[DatabaseManagement / DatabaseDiagnostics()] : Mismatch on the SID entries. Attempting to recreate accounts");
                // Try to create user
                CreateOMLUser(sqlConn);
                return(DatabaseInformation.SQLState.OMLUserNotFound);
            }


            sqlConn.Close();
            sqlConn.Dispose();

            CustomActions.LogToSession("[DatabaseManagement] : Leaving DatabaseDiagnostics()");

            return(DatabaseInformation.SQLState.OK);
        }