Exemple #1
0
 protected override void Install()
 {
     if (ModeExtension == ModeExtension.Normal)
     {
         bool WiXThrow = default(bool);
         Context.ComponentId = Guid.NewGuid().ToString();
         Context.Instance = String.Empty;
         var sam = new WiXEnterpriseServerActionManager(Context);
         sam.PrepareDistributiveDefaults();
         try
         {
             sam.ActionError += new EventHandler<ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) =>
             {
                 Log.WriteError(e.ErrorMessage);
                 WiXThrow = true;
             });
             sam.Start();
         }
         catch (Exception ex)
         {
             Log.WriteError("Failed to install the component", ex);
         }
         if (WiXThrow)
             InstallFailed();
     }
     else if (ModeExtension == ModeExtension.Restore)
     {
         Context.ComponentId = GetComponentID(Context);
         Context.UseUserCredentials = false;
         AppConfig.LoadComponentSettings(Context);
         if (string.IsNullOrWhiteSpace(Context.ServiceName) || string.IsNullOrWhiteSpace(Context.ServiceFile))
         {
             Context.ServiceName = Global.Parameters.SchedulerServiceName;
             Context.ServiceFile = Path.Combine(Context.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName);
         }                
         SetupScript Script = new RestoreScript(Context);
         Script.Run();
         Script = new ExpressScript(Context);
         var XmlUp = new Dictionary<string, string[]>();
         XmlUp.Add("configuration/connectionStrings/add[@name='EnterpriseServer']", new string[] {"connectionString", Context.ConnectionString});
         XmlUp.Add("configuration/appSettings/add[@key='WebsitePanel.CryptoKey']", new string[] {"value", Context.CryptoKey });
         Context.XmlData = XmlUp;
         Script.Actions.Add(new InstallAction(ActionTypes.UpdateXml) { SetupVariables = Context, Path = string.Format("{0}.config", Context.ServiceFile) });
         Script.Actions.Add(new InstallAction(ActionTypes.RegisterWindowsService));
         Script.Actions.Add(new InstallAction(ActionTypes.StartWindowsService));                
         Script.Run();                
     }
     else
         throw new NotImplementedException("Install " + ModeExtension.ToString());
 }
Exemple #2
0
 protected override void Install()
 {
     if (ModeExtension == ModeExtension.Normal)
     {
         bool WiXThrow = default(bool);
         Context.ComponentId = Guid.NewGuid().ToString();
         Context.Instance = String.Empty;
         var sam = new WiXEnterpriseServerActionManager(Context);
         sam.PrepareDistributiveDefaults();
         try
         {
             sam.ActionError += new EventHandler<ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) =>
             {
                 Log.WriteError(e.ErrorMessage);
                 WiXThrow = true;
             });
             sam.Start();
         }
         catch (Exception ex)
         {
             Log.WriteError("Failed to install the component", ex);
         }
         if (WiXThrow)
             InstallFailed();
     }
     else if (ModeExtension == ModeExtension.Restore)
     {
         Context.ComponentId = GetComponentID(Context);
         Context.UseUserCredentials = false;
         AppConfig.LoadComponentSettings(Context);
         SetupScript Script = new RestoreScript(Context);
         Script.Run();
     }
     else
         throw new NotImplementedException("Install " + ModeExtension.ToString());
 }