public bool BuildIndividualPackage(string folder, string targetEnvironment, string package)
        {
            var storageProvider   = StorageFactory.GetDefaultProvider();
            BaseChangePackage bcp = storageProvider.LoadPackage(System.IO.Path.Combine(folder, package));
            var variables         = EnvironmentManager.LoadVariables(System.IO.Path.GetDirectoryName(bcp.PackageLocation), bcp.DefaultBuildVariableSet);

            bcp.UpdateRuntimeData(variables);
            bcp.Build(storageProvider);
            return(true);
        }
        public void MarkPackageAsDeployed(BaseChangePackage package)
        {
            Hashtable         variableValues  = EnvironmentManager.LoadVariables(System.IO.Path.GetDirectoryName(package.PackageLocation), package.DefaultRunVariableSet);
            var               storageProvider = StorageFactory.GetDefaultProvider();
            BaseChangePackage bcp             = storageProvider.LoadPackage(package.PackageLocation);

            bcp.UpdateRuntimeData(variableValues);
            BaseComponent.Log.Info("Package loaded: " + bcp.Name);
            bcp.LogPackageDeployment();
            BaseComponent.Log.Info("Deployment status updated: " + bcp.Name);
        }
        static public List <BaseSolution> GetSolutionList(BaseChangePackage pkg)
        {
            if (solutionList == null)
            {
                GetSolutionList();
            }
            List <BaseSolution> result = new List <BaseSolution>();

            foreach (var x in solutionList)
            {
                if (x.SupportedPackageTypes.IndexOf(pkg.GetType()) > -1)
                {
                    result.Add(x);
                }
            }
            return(result);
        }
Exemple #4
0
 private void InternalBuild()
 {
     try
     {
         PackageRunner     pr        = new PackageRunner();
         var               variables = EnvironmentManager.LoadVariables(System.IO.Path.GetDirectoryName(Package.PackageLocation), Package.DefaultBuildVariableSet);
         BaseChangePackage bcp       = storageProvider.LoadPackage(Package.PackageLocation);
         bcp.UpdateRuntimeData(variables);
         bcp.Build(storageProvider);
     }
     catch (Exception ex)
     {
         threadException = ex;
     }
     finally
     {
         inProgress = false;
     }
 }
 public bool SavePackage(BaseChangePackage package, string location = null)
 {
     if (package == null)
     {
         return(true);
     }
     location = location == null ? package.PackageLocation : location;
     if (location == null)
     {
         return(SavePackageAs(package));
     }
     else
     {
         XmlSerializer ser    = new XmlSerializer(typeof(BaseChangePackage), KnownTypes.ToArray());
         TextWriter    writer = new StreamWriter(location);
         ser.Serialize(writer, package);
         writer.Close();
         package.HasUnsavedChanges = false;
         return(true);
     }
 }
        public BaseChangePackage LoadPackage(string location = null)
        {
            BaseChangePackage result = null;

            if (location == null)
            {
                using (var fd = new System.Windows.Forms.OpenFileDialog())
                {
                    fd.DefaultExt  = "ecp";
                    fd.Filter      = "EZChange Files (*.ecp)|*.ecp|All files (*.*)|*.*";
                    fd.FilterIndex = 1;
                    if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        location = fd.FileName;
                    }
                    else
                    {
                        return(result);
                    }
                }
            }
            if (location != null)
            {
                XmlSerializer ser    = new XmlSerializer(typeof(BaseChangePackage), KnownTypes.ToArray());
                TextReader    reader = new StreamReader(location);
                result = (BaseChangePackage)ser.Deserialize(reader);
                result.PackageLocation = location;
                result.InitializeComponents();
                reader.Close();
            }
            if (result != null)
            {
                foreach (var s in result.Solutions)
                {
                    s.Package = result;
                }
            }

            return(result);
        }
 public bool SavePackageAs(BaseChangePackage package)
 {
     if (package == null)
     {
         return(true);
     }
     using (var fd = new System.Windows.Forms.SaveFileDialog())
     {
         fd.DefaultExt  = "ecp";
         fd.Filter      = "EZChange Files (*.ecp)|*.ecp|All files (*.*)|*.*";
         fd.FilterIndex = 1;
         if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             package.PackageLocation = fd.FileName;
             SavePackage(package);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #8
0
        private void NewPackage()
        {
            if (SaveIfRequired())
            {
                ItemSelector selector = new ItemSelector();
                selector.Initialize(PackageFactory.GetPackageList().ToList <object>(), "Package Type");
                if (selector.ShowIfMultiple() == DialogResult.OK && selector.SelectedItem != null)
                {
                    BaseChangePackage pkg = PackageFactory.CreatePackage((BaseChangePackage)selector.SelectedItem);
                    pkg.HasUnsavedChanges = false;
                    ComponentControl ac = new ComponentControl();

                    pkg.Name = "New Change Package";
                    ac.Setup(pkg, "Package Properties");

                    if (ac.ShowDialog() == DialogResult.OK)
                    {
                        ac.UpdateComponent(pkg);
                        Package = pkg;
                    }
                }
            }
        }
        public bool RunIndividualPackage(string location, Hashtable variables, BaseAction selectedAction, string selectedActionId, bool checkIfDeployed)
        {
            var storageProvider = StorageFactory.GetDefaultProvider();

            try
            {
                BaseComponent.Log.Info("Starting the package..");
                BaseChangePackage bcp = storageProvider.LoadPackage(location);


                /*
                 * if (variables == null)
                 * {
                 *  variables = new Hashtable();
                 *  foreach (var v in bcp.Variables)
                 *  {
                 *      variables[v.Name] = v.Value;
                 *  }
                 * }
                 */
                bcp.UpdateRuntimeData(variables);
                BaseComponent.Log.Info("Package loaded: " + bcp.Name);

                if (selectedAction == null && selectedActionId != null)
                {
                    Guid actionId = Guid.Parse(selectedActionId);
                    foreach (var s in bcp.Solutions)
                    {
                        selectedAction = s.FindAction(actionId);
                        if (selectedAction != null)
                        {
                            break;
                        }
                    }
                }

                if (selectedAction != null || !checkIfDeployed || !bcp.IsPackageDeployed())
                {
                    bcp.Run(selectedAction);
                    if (selectedAction == null && checkIfDeployed)
                    {
                        bcp.LogPackageDeployment();
                    }
                }
                else
                {
                    BaseComponent.LogInfo("This package has already been deployed");
                }
            }
            catch (Exception ex)
            {
                BaseComponent.Log.Error(ex.Message);
                throw;
            }
            finally
            {
                BaseComponent.Log.Info("Done");
            }

            return(true);
        }
 static public BaseChangePackage CreatePackage(BaseChangePackage packageDesecription)
 {
     return((BaseChangePackage)Activator.CreateInstance(packageDesecription.GetType()));
 }