Ejemplo n.º 1
0
        public VersionViewModel(IRelease[] releases)
        {
            Releases = releases.OrderBy(x => x.VersionSize).ToList();

            GoToNext     = new DelegateCommand <object>(GoToNextExecute, o => GoToNextCanExecute);
            GoToPrevious = new DelegateCommand <object>(GoToPreviousExecute, o => GoToPreviousCanExecute);

            Index = Releases.Count() - 1;
        }
        /// <summary> <para>This internal function returns a list of installable items based on a
        /// pre-selected list of releases passed in.</para> <para>It can take an array of releases
        /// or a single release. Pass in no value for release and it will return for all configured
        /// releases.</para>
        /// <para>List of Release (class) rels - Metadata from Initialize procedure filtered
        /// by public calls.</para>
        /// </summary>
        /// <param name="rels"></param>
        /// <param name="getall"></param>
        /// <returns>List Bundle</returns>
        private ICollection <Bundle> GetDataFromPdb(ICollection <Bundle> rels, bool getall)
        {
            ICollection <Bundle> installables = new List <Bundle>();

            Logger.Log("GetDataFromPdb started.");

            Logger.Log(String.Format(CultureInfo.InvariantCulture, " - Select releases: {0}", Releases.Count(x => x.Selected).ToString(CultureInfo.InvariantCulture)));
            Logger.Log(String.Format(CultureInfo.InvariantCulture, " - Get all WixPdbs: {0}", getall.ToString(CultureInfo.InvariantCulture)));
            if (Releases.Count(x => x.Selected) != 0 || getall)
            {
                try
                {
                    Logger.Log(String.Format(CultureInfo.InvariantCulture, " -- Releases: {0}", rels == null ? "Null" : rels.Count().ToString(CultureInfo.InvariantCulture)));
                    if (releases == null || releases.ElementAt(0).Packages == null || getall)
                    {
                        if ((rels == null) || (releases == null))
                        {
                            GetContent(ref releases, DataFilesPath);
                        }

                        if (getall)
                        {
                            rels = Releases;
                        }

                        foreach (Bundle rel in rels)
                        {
                            var filetype = rel.FileType;
                            var filepath = (filetype == FILETYPE_WIXPDB) ? rel.Path : rel.xmlPath;
                            if (getall)
                            {
                                filetype = FILETYPE_WIXPDB;
                                filepath = rel.Path;
                            }
                            if (File.Exists(filepath))
                            {
                                GetDataFromSource(installables, rel, filetype, filepath);
                            }
                            else
                            {
                                throw new FileNotFoundException(String.Format(CultureInfo.InvariantCulture, "Error File Not Found: {0}", rel.Path), rel.Path);
                            }
                        }
                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Installables count: {0}", installables.Count().ToString(CultureInfo.InvariantCulture), AppName));
                        releases = installables;
                    }
                    else
                    {
                        installables = releases;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
            else
            {
                var msg = "A release has not been selected for use with this method.  Property UserSelectedReleases needs to be set.";
                Logger.Log(msg);
                throw new Exception(msg);
            }

            Processed = true;
            Logger.Log("GetDataFromPdb ended.");
            SaveAll();
            installables = getall ? installables : installables.Where(x => x.Selected).ToList();
            return(installables);
        }