Example #1
0
        public static ActionResult OnScpa(Session Ctx)
        {
            PopUpDebugger();
            Func<Hashtable, string, string> GetParam = (s, x) => Utils.GetStringSetupParameter(s, x);
            Ctx.AttachToSetupLog();
            Log.WriteStart("OnScpa");

            try
            {
                var Hash = Ctx.CustomActionData.ToNonGenericDictionary() as Hashtable;
                var Scpa = new WebsitePanel.Setup.Actions.ConfigureStandaloneServerAction();
                Scpa.ServerSetup = new SetupVariables { };
                Scpa.EnterpriseServerSetup = new SetupVariables { };
                Scpa.PortalSetup = new SetupVariables { };
                Scpa.EnterpriseServerSetup.ServerAdminPassword = GetParam(Hash, "ServerAdminPassword");
                Scpa.EnterpriseServerSetup.PeerAdminPassword = Scpa.EnterpriseServerSetup.ServerAdminPassword;
                Scpa.PortalSetup.InstallerFolder = GetParam(Hash, "InstallerFolder");
                Scpa.PortalSetup.ComponentId = WiXSetup.GetComponentID(Scpa.PortalSetup);
                AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = WiXSetup.GetFullConfigPath(Scpa.PortalSetup) });
                Scpa.PortalSetup.EnterpriseServerURL = GetParam(Hash, "EnterpriseServerUrl");
                Scpa.PortalSetup.WebSiteIP = GetParam(Hash, "PortalWebSiteIP");
                Scpa.ServerSetup.WebSiteIP = GetParam(Hash, "ServerWebSiteIP");
                Scpa.ServerSetup.WebSitePort = GetParam(Hash, "ServerWebSitePort");
                Scpa.ServerSetup.ServerPassword = GetParam(Hash, "ServerPassword");
                var Make = Scpa as WebsitePanel.Setup.Actions.IInstallAction;
                Make.Run(null);
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
            }
            Log.WriteEnd("OnScpa");
            return ActionResult.Success;
        }
Example #2
0
        public static ActionResult OnEServerPrepare(Session Ctx)
        {
            PopUpDebugger();

            Ctx.AttachToSetupLog();
            Log.WriteStart("OnEServerPrepare");
            GetPrepareScript(Ctx).Run();
            Log.WriteEnd("OnEServerPrepare");
            return ActionResult.Success;
        }
Example #3
0
 public static ActionResult GetDbSkip(Session Ctx)
 {
     PopUpDebugger();
     Ctx.AttachToSetupLog();
     Log.WriteStart("GetDbSkip");
     var ConnStr = Ctx["DB_CONN"];
     var DbName = Ctx["DB_DATABASE"];
     var Tmp = Adapter.SkipCreateDb(ConnStr, DbName) ? YesNo.Yes : YesNo.No;
     Log.WriteInfo("DB_SKIP_CREATE is " + Tmp);
     Ctx["DB_SKIP_CREATE"] = Tmp;
     Log.WriteEnd("GetDbSkip");
     return ActionResult.Success;
 }
Example #4
0
 public static ActionResult CheckConnectionSchedulerUI(Session Ctx)
 {
     PopUpDebugger();
     Ctx.AttachToSetupLog();
     Log.WriteStart("CheckConnectionSchedulerUI");
     var Result = default(bool);
     var Msg = default(string);
     var DbServer = Ctx["PI_SCHEDULER_DB_SERVER"];
     var DbUser = Ctx["PI_SCHEDULER_DB_LOGIN"];
     var DbPass = Ctx["PI_SCHEDULER_DB_PASSWORD"];
     var DbBase = Ctx["PI_SCHEDULER_DB_DATABASE"];
     if (new string[] { DbServer, DbUser, DbPass, DbBase }.Any(x => string.IsNullOrWhiteSpace(x)))
         Msg = "Please check all fields again.";
     else
         Result = Adapter.CheckSql(new SetupVariables { InstallConnectionString = GetConnectionString(DbServer, DbBase, DbUser, DbPass) }, out Msg) == CheckStatuses.Success;
     Ctx["DB_CONN_CORRECT"] = Result ? YesNo.Yes : YesNo.No;
     Ctx["DB_CONN_MSG"] = string.Format(Result ? "Success. {0}" : "Error. {0}", Msg);
     Log.WriteEnd("CheckConnectionSchedulerUI");
     return ActionResult.Success;
 }
Example #5
0
 public static ActionResult OnSchedulerPrepare(Session Ctx)
 {
     PopUpDebugger();
     Ctx.AttachToSetupLog();
     Log.WriteStart("OnSchedulerPrepare");
     try
     {
         var ServiceName = Global.Parameters.SchedulerServiceName;
         var ServiceFile = string.Empty;
         ManagementClass WmiService = new ManagementClass("Win32_Service");
         foreach (var MObj in WmiService.GetInstances())
         {
             if (MObj.GetPropertyValue("Name").ToString().Equals(ServiceName, StringComparison.CurrentCultureIgnoreCase))
             {
                 ServiceFile = MObj.GetPropertyValue("PathName").ToString();
                 break;
             }
         }
         if (!string.IsNullOrWhiteSpace(ServiceName) && !string.IsNullOrWhiteSpace(ServiceFile))
         {
             var CtxVars = new SetupVariables() { ServiceName = ServiceName, ServiceFile = ServiceFile };
             var Script = new BackupSchedulerScript(CtxVars);
             Script.Actions.Add(new InstallAction(ActionTypes.UnregisterWindowsService)
             {
                 Name = ServiceName,
                 Path = ServiceFile,
                 Description = "Removing Windows service...",
                 Log = string.Format("- Remove {0} Windows service", ServiceName)
             });
             Script.Context.ServiceName = Global.Parameters.SchedulerServiceName;
             Script.Run();
         }
     }
     catch (Exception ex)
     {
         Log.WriteError(ex.ToString());
     }
     Log.WriteEnd("OnSchedulerPrepare");
     return ActionResult.Success;
 }
Example #6
0
 private static ActionResult ProcessInstall(Session Ctx, WiXInstallType InstallType)
 {
     IWiXSetup Install = null;
     try
     {
         Ctx.AttachToSetupLog();
         switch (InstallType)
         {
             case WiXInstallType.InstallServer:
                 Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Install);
                 break;
             case WiXInstallType.RemoveServer:
                 Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall);
                 break;
             case WiXInstallType.MaintenanceServer:
                 Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Setup);
                 break;
             case WiXInstallType.InstallEnterpriseServer:
                 Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Install);
                 break;
             case WiXInstallType.RemoveEnterpriseServer:
                 Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall);
                 break;
             case WiXInstallType.MaintenanceEnterpriseServer:
                 Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Setup);
                 break;
             case WiXInstallType.InstallPortal:
                 Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Install);
                 break;
             case WiXInstallType.RemovePortal:
                 Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall);
                 break;
             case WiXInstallType.MaintenancePortal:
                 Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Setup);
                 break;
             case WiXInstallType.InstallScheduler:
                 Install = SchedulerSetup.Create(Ctx.CustomActionData, SetupActions.Install);
                 break;
             case WiXInstallType.RemoveScheduler:
                 Install = SchedulerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall);
                 break;
             default:
                 throw new NotImplementedException();
         }
         Install.Run();
     }
     catch (WiXSetupException we)
     {
         Ctx.Log("Expected exception: " + we.ToString());
         return ActionResult.Failure;
     }
     catch (Exception ex)
     {
         Ctx.Log(ex.ToString());
         return ActionResult.Failure;
     }
     return ActionResult.Success;
 }
Example #7
0
 public static ActionResult PortalNormalizeLoginUI(Session Ctx)
 {
     Ctx.AttachToSetupLog();
     try
     {
         NormalizeLoginUI(Ctx, "PORTAL");
     }
     catch (Exception ex)
     {
         Log.WriteError("Error in login", ex);
     }
     return ActionResult.Success;
 }
Example #8
0
        public static ActionResult InstallRollback(Session Ctx)
        {
            PopUpDebugger();
            Ctx.AttachToSetupLog();
            const string Title = "Rolling back component";
            Log.WriteStart(Title);
            Log.WriteInfo("It is normal that here occurs error.");
            try
            {
                SetupVariables SetupVar = new SetupVariables();
                WiXSetup.FillFromSession(Ctx.CustomActionData, SetupVar);
                SetupVar.IISVersion = Tool.GetWebServerVersion();
                SetupVar.ComponentId = GetProperty(Ctx, "ComponentId");

                SetupVar.WebSiteId = SetupVar.ComponentFullName;
                SetupVar.WebApplicationPoolName = string.Format("{0} Pool", SetupVar.ComponentFullName);
                SetupVar.DatabaseUser = SetupVar.Database;

                SetupScript Script = new ExpressScript(SetupVar);
                InstallAction Act = null;

                Act = new InstallAction(ActionTypes.DeleteWebSite);
                Act.SiteId = SetupVar.WebSiteId;
                Act.Description = "Deleting web site...";
                Act.Log = string.Format("- Delete {0} web site", SetupVar.WebSiteId);
                Script.Actions.Add(Act);

                Act = new InstallAction(ActionTypes.DeleteApplicationPool);
                Act.Name = SetupVar.ApplicationPool;
                Act.Description = "Deleting application pool...";
                Act.Log = string.Format("- Delete {0} application pool", SetupVar.ApplicationPool);
                Script.Actions.Add(Act);

                if (SetupVar.UserMembership != null && SetupVar.UserMembership.Length > 0)
                {
                    Act = new InstallAction(ActionTypes.DeleteUserMembership);
                    Act.Name = SetupVar.UserAccount;
                    Act.Domain = SetupVar.UserDomain;
                    Act.Membership = SetupVar.UserMembership;
                    Act.Description = "Removing user account membership...";
                    Act.Log = string.Format("- Remove {0} user account membership", SetupVar.UserAccount);
                    Script.Actions.Add(Act);
                }

                if (SetupVar.NewUserAccount)
                {
                    Act = new InstallAction(ActionTypes.DeleteUserAccount);
                    Act.Name = SetupVar.UserAccount;
                    Act.Domain = SetupVar.UserDomain;
                    Act.Description = "Deleting user account...";
                    Act.Log = string.Format("- Delete {0} user account", SetupVar.UserAccount);
                    Script.Actions.Add(Act);
                }

                if (SetupVar.ComponentCode == Global.EntServer.ComponentCode)
                {
                    Act = new InstallAction(ActionTypes.DeleteDatabaseUser);
                    Act.ConnectionString = SetupVar.InstallConnectionString;
                    Act.UserName = SetupVar.DatabaseUser;
                    Act.Description = "Deleting database user...";
                    Act.Log = string.Format("- Delete {0} database user", SetupVar.DatabaseUser);
                    Script.Actions.Add(Act);

                    Act = new InstallAction(ActionTypes.DeleteDatabaseLogin);
                    Act.ConnectionString = SetupVar.InstallConnectionString;
                    Act.UserName = SetupVar.DatabaseUser;
                    Act.Description = "Deleting database login...";
                    Act.Log = string.Format("- Delete {0} database login", SetupVar.DatabaseUser);
                    Script.Actions.Add(Act);
                }

                if (SetupVar.ComponentCode == Global.WebPortal.ComponentCode)
                {
                    Act = new InstallAction(ActionTypes.DeleteShortcuts);
                    Act.Description = "Deleting shortcuts...";
                    Act.Log = "- Delete shortcuts";
                    Act.Name = "Login to MSPControl.url";
                    Script.Actions.Add(Act);
                }

                Script.Run();
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
            }
            Log.WriteEnd(Title);
            return ActionResult.Success;
        }
Example #9
0
        public static ActionResult SchedulerInstallRollback(Session Ctx)
        {
            PopUpDebugger();
            Ctx.AttachToSetupLog();
            const string LogExt = ".InstallLog";
            const string Title = "Rolling back component";
            Log.WriteStart(Title);
            Log.WriteInfo("It is normal that here occurs error.");
            try
            {
                SetupVariables SetupVar = new SetupVariables();
                WiXSetup.FillFromSession(Ctx.CustomActionData, SetupVar);
                SetupVar.IISVersion = Tool.GetWebServerVersion();
                SetupVar.ComponentId = GetProperty(Ctx, "ComponentId");

                SetupVar.ServiceName = Global.Parameters.SchedulerServiceName;
                SetupVar.ServiceFile = Path.Combine(SetupVar.InstallationFolder, Global.Parameters.SchedulerServiceFileName);

                var Script = new ExpressScript(SetupVar);
                Script.Actions.Add(new InstallAction(ActionTypes.UnregisterWindowsService)
                {
                    Name = SetupVar.ServiceName,
                    Path = SetupVar.ServiceFile,
                    Description = string.Format("Removing Windows service '{0}' ...", SetupVar.ServiceFile),
                    Log = string.Format("- Remove {0} Windows service", SetupVar.ServiceName)
                });
                Script.Actions.Add(new InstallAction(ActionTypes.DeleteDirectoryFiles)
                {
                    Path = SetupVar.InstallFolder,
                    FileFilter = x => x.ToLowerInvariant().EndsWith(LogExt.ToLowerInvariant())
                });

                Script.Run();
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
            }
            Log.WriteEnd(Title);
            return ActionResult.Success;
        }