예제 #1
0
 public WikiFile(int id)
 {
     using (var reader = Application.SqlHelper.ExecuteReader("SELECT * FROM wikiFiles WHERE id = @fileId",
                                                             Application.SqlHelper.CreateParameter("@fileId", id)))
     {
         if (reader.Read())
         {
             Id            = reader.GetInt("id");
             Path          = reader.GetString("path");
             Name          = reader.GetString("name");
             FileType      = reader.GetString("type");
             RemovedBy     = reader.GetInt("removedBy");
             CreatedBy     = reader.GetInt("createdBy");
             NodeVersion   = reader.GetGuid("version");
             NodeId        = reader.GetInt("nodeId");
             CreateDate    = reader.GetDateTime("createDate");
             Current       = reader.GetBoolean("current");
             Downloads     = reader.GetInt("downloads");
             Archived      = reader.GetBoolean("archived");
             Verified      = reader.GetBoolean("verified");
             DotNetVersion = reader.GetString("dotNetVersion");
             Versions      = GetVersionsFromString(reader.GetString("umbracoVersion"));
             Version       = Versions.Any()
                 ? GetVersionsFromString(reader.GetString("umbracoVersion"))[0]
                 : UmbracoVersion.DefaultVersion();
             MinimumVersionStrict = reader.GetString("minimumVersionStrict");
         }
         else
         {
             throw new ArgumentException(string.Format("No node exists with id '{0}'", Id));
         }
     }
 }
예제 #2
0
        public WikiFile(int id)
        {
            umbraco.DataLayer.IRecordsReader dr = Data.SqlHelper.ExecuteReader("SELECT * FROM wikiFiles WHERE id = " + id.ToString());

            if (dr.Read())
            {
                Id          = dr.GetInt("id");
                Path        = dr.GetString("path");
                Name        = dr.GetString("name");
                FileType    = dr.GetString("type");
                RemovedBy   = dr.GetInt("removedBy");
                CreatedBy   = dr.GetInt("createdBy");
                NodeVersion = dr.GetGuid("version");
                NodeId      = dr.GetInt("nodeId");
                CreateDate  = dr.GetDateTime("createDate");
                Current     = dr.GetBoolean("current");
                Downloads   = dr.GetInt("downloads");
                Archived    = dr.GetBoolean("archived");
                Verified    = dr.GetBoolean("verified");
                Versions    = GetVersionsFromString(dr.GetString("umbracoVersion"));
                Version     = Versions.Any() ? GetVersionsFromString(dr.GetString("umbracoVersion"))[0] : UmbracoVersion.DefaultVersion();
            }
            else
            {
                throw new ArgumentException(string.Format("No node exists with id '{0}'", Id));
            }

            dr.Close();
        }
예제 #3
0
        void Read(JArray items)
        {
            foreach (var v in items)
            {
                var listed = v["catalogEntry"]?["listed"] ?? true;
                if (!(bool)listed)
                {
                    continue;
                }

                DateTime?time  = null;
                var      times = v["catalogEntry"]?["published"];
                if (times != null)
                {
                    time = (DateTime)times;
                }

                var version = v["version"]?.ToString();
                if (version == null)
                {
                    version = v["catalogEntry"]?["version"]?.ToString();
                }
                if (version != null && !Versions.Any(x => string.Equals(x.LongVersionString, version, StringComparison.OrdinalIgnoreCase)))
                {
                    var pv = new PackageVersion {
                        LongVersionString = version, PublishTime = time
                    };
                    Versions.Add(pv);
                }
                Versions.Sort();
            }
        }
예제 #4
0
        // check if schema version in User database and EntityConstants match
        public bool CheckSchemaVersion()
        {
            var match = Versions.Any(v => v.VersionType == DatabaseVersion.Schema && v.VersionString == UserConstants.SchemaVersion);

            if (match == false)
            {
                TraceLog.TraceError(String.Format("User database schema version {0} not found", UserConstants.SchemaVersion));
            }
            return(match);
        }
예제 #5
0
 public VC GetDatabaseVersions(string dbName)
 {
     if (!Versions.Any(x => x.Name == dbName))
     {
         Versions.Add(new VC()
         {
             Name = dbName
         });
     }
     return(Versions.FirstOrDefault(x => x.Name == dbName));
 }
예제 #6
0
        public async Task OnGet()
        {
            Versions = (await _documentAppService.GetVersions(ProjectName, DocumentName))
                       .Select(v => new VersionInfo(v, v))
                       .ToList();

            var hasAnyVersion = Versions.Any();

            AddDefaultVersionIfNotContains();

            var latestVersion = hasAnyVersion ? Versions[1] : Versions[0];

            latestVersion.DisplayText = $"{latestVersion.Version} - latest";
            latestVersion.Version     = latestVersion.Version;


            var versionFromUrl = Versions.FirstOrDefault(v => v.Version == Version);

            if (versionFromUrl != null)
            {
                versionFromUrl.IsSelected = true;
            }
            else if (string.Equals(Version, "latest", StringComparison.InvariantCultureIgnoreCase))
            {
                latestVersion.IsSelected = true;
            }
            else
            {
                Versions.First().IsSelected = true;
            }

            if (Version == null)
            {
                Version = Versions.Single(x => x.IsSelected).Version;
            }

            Document = await _documentAppService.GetByNameAsync(ProjectName, DocumentName, Version, true);

            var converter = _documentConverterFactory.Create(Document.Format ?? "md");
            var content   = converter.NormalizeLinks(Document.Content, Document.Project.ShortName, Document.Version, Document.LocalDirectory);

            content = converter.Convert(content);

            content          = HtmlNormalizer.ReplaceImageSources(content, Document.RawRootUrl, Document.LocalDirectory);
            content          = HtmlNormalizer.ReplaceCodeBlocksLanguage(content, "language-C#", "language-csharp"); //todo find a way to make it on client in prismJS configuration (eg: map C# => csharp)
            Document.Content = content;

            Navigation = await _documentAppService.GetNavigationDocumentAsync(ProjectName, Version, false);

            Navigation.ConvertItems();
        }
예제 #7
0
파일: ISOInfo.cs 프로젝트: Jriyuu/SharpBoot
 public ISOInfo(string name, Dictionary <CultureInfo, string> descs, ISOCat cat, string fn = "",
                params ISOV[] vers)
 {
     Name         = name;
     Descriptions = descs;
     Category     = cat;
     Filename     = fn;
     Versions     = vers.ToList();
     Versions.ForEach(x => x.Parent = this);
     if (!Versions.Any(x => x.Latest) && Versions.Count > 0)
     {
         Versions.Where(t => LatestVersion == t).ToList()[0].Latest = true;
     }
 }
예제 #8
0
        private static async Task <IEnumerable <Version> > DownloadNewVersionsAsync()
        {
            if (Versions?.Count == 0)
            {
                await CreateVersionsFromFirebaseStorageAsync();
            }

            Logger.WriteLine("Downloading Version Manifest data.");
            var versionManifest = await DownloadVersionManifestAsync();

            var missingVersions = versionManifest.Versions.Where(v => !Versions.Any(v2 => v2.Id == v.Id));

            return(await DownloadVersionsAsync(missingVersions));
        }
예제 #9
0
        public MainWindowViewModel(IRegistryService registryService, IFileService fileService)
        {
            this.registryService = registryService;
            this.fileService     = fileService;

            BrowseForFolderCommand = new DelegateCommand(OnBrowseForFolderCommand);
            UpdateRegistryCommand  = new DelegateCommand(OnUpdateRegistryCommand, new Predicate <object>(o => fileService.IsDirectoyOnDisk(NewSharedDirectory)));

            Versions = registryService.GetVersions();
            if (Versions.Any())
            {
                SelectedVersion = Versions[0];
            }
        }
예제 #10
0
        static void Init(DotNetCorePath path)
        {
            IsInstalled = !path.IsMissing;
            FileName    = path.FileName;

            Versions = DotNetCoreRuntimeVersions.GetInstalledVersions(path)
                       .OrderByDescending(version => version)
                       .ToArray();

            // If there are no runtimes then do not consider the runtime to be installed.
            if (!Versions.Any())
            {
                IsInstalled = false;
            }

            // Used by the DotNetMSBuildSdkResolver to find the .NET Core SDK.
            // Not sure this is needed - seems to work without it.
            Environment.SetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", path.ParentDirectory);
        }
예제 #11
0
 void Read(JArray items)
 {
     foreach (var v in items)
     {
         DateTime?time  = null;
         var      times = v["catalogEntry"]?["published"];
         if (times != null)
         {
             time = (DateTime)times;
         }
         var version = v["version"]?.ToString();
         if (version == null)
         {
             version = v["catalogEntry"]?["version"]?.ToString();
         }
         if (version != null && !Versions.Any(x => string.Equals(x.VersionString, version, StringComparison.OrdinalIgnoreCase)))
         {
             Versions.Add(new PackageVersion {
                 VersionString = version, PublishTime = time
             });
         }
     }
 }
예제 #12
0
 public WikiFile(int id)
 {
     using (var sqlHelper = Application.SqlHelper)
         using (var reader = sqlHelper.ExecuteReader("SELECT * FROM wikiFiles WHERE id = @fileId", sqlHelper.CreateParameter("@fileId", id)))
         {
             {
                 if (reader.Read())
                 {
                     Id            = reader.GetInt("id");
                     Path          = reader.GetString("path");
                     Name          = reader.GetString("name");
                     FileType      = reader.GetString("type");
                     RemovedBy     = reader.GetInt("removedBy");
                     CreatedBy     = reader.GetInt("createdBy");
                     NodeVersion   = reader.GetGuid("version");
                     NodeId        = reader.GetInt("nodeId");
                     CreateDate    = reader.GetDateTime("createDate");
                     Current       = reader.GetBoolean("current");
                     Downloads     = reader.GetInt("downloads");
                     Archived      = reader.GetBoolean("archived");
                     Verified      = reader.GetBoolean("verified");
                     DotNetVersion = reader.GetString("dotNetVersion");
                     Versions      = GetVersionsFromString(reader.GetString("umbracoVersion"));
                     Version       = Versions.Any()
                     ? GetVersionsFromString(reader.GetString("umbracoVersion"))[0]
                     : UmbracoVersion.DefaultVersion();
                     MinimumVersionStrict = reader.GetString("minimumVersionStrict");
                 }
                 else
                 {
                     HttpContext.Current.Response.StatusCode = 404;
                     HttpContext.Current.Response.End();
                 }
             }
         }
 }
예제 #13
0
        protected override async Task ProcessRecordAsync()
        {
            if (Name == null && (Versions == null || !Versions.Any()))
            {
                await Providers.ListPackages(Source, IncludeDelisted, AllVersions, IncludePrerelease)
                .HandleErrors(this).WriteObject(this);

                return;
            }
            var listPackages = Name != null?Observable.Return(Name)
                                   : Providers.ListPackages(Source, IncludeDelisted, false, IncludePrerelease).ToPackageObject().Select(_ => _.Id);

            var metaData = listPackages
                           .SelectMany(package => SelectPackages(package, Providers))
                           .Where(metadata => metadata != null)
                           .HandleErrors(this)
                           .Distinct(new MetadataComparer()).Replay().AutoConnect();
            var searchMetadata = await metaData.DefaultIfEmpty();

            if (searchMetadata == null)
            {
                return;
            }
            var packageSearchMetadatas = metaData.ToEnumerable().ToArray()
                                         .OrderByDescending(_ => _.Identity.Version.Version).ToArray();

            if (!AllVersions && Versions == null)
            {
                WriteObject(packageSearchMetadatas.OrderByDescending(metadata => metadata.Identity.Version.Version).FirstOrDefault());
                return;
            }
            foreach (var packageSearchMetadata in packageSearchMetadatas.Where(VersionMatch))
            {
                WriteObject(packageSearchMetadata);
            }
        }
예제 #14
0
 internal static bool IsNetCore1xInstalled()
 {
     return(Versions.Any(version => version.Major == 1));
 }
 private bool ValidateAttachments()
 {
     return(Attachments.Count == Versions.Count &&
            Attachments.All(kvp => Versions.Any(v => PackageUtils.GetTarballName(Name, v.Key) == kvp.Key) && IsValidBase64String(kvp.Value.Data)));
 }
예제 #16
0
 public bool VersionNameExists(string version_name)
 {
     return(Versions.Any(v => v.Name == version_name));
 }
예제 #17
0
 internal static bool IsNetCore20Installed()
 {
     return(Versions.Any(version => version.Major == 2 && version.Minor == 0));
 }
예제 #18
0
        // update constants in User database to current version defined in EntityConstants
        public bool VersionConstants(string me)
        {
            try
            {
                bool updateDB = false;
                if (Versions.Any(v => v.VersionType == DatabaseVersion.Constants && v.VersionString == UserConstants.ConstantsVersion) == false)
                {   // no database - create and lock the new version entry
                    TraceLog.TraceInfo(String.Format("User database version {0} not found", UserConstants.ConstantsVersion));

                    // remove an existing database version (there should never be more than one)
                    foreach (var existingVersion in Versions.Where(v => v.VersionType == DatabaseVersion.Constants).ToList())
                    {
                        Versions.Remove(existingVersion);
                    }
                    SaveChanges();

                    // create the new version entry
                    DatabaseVersion ver = new DatabaseVersion()
                    {
                        VersionType   = DatabaseVersion.Constants,
                        VersionString = UserConstants.ConstantsVersion,
                        Status        = me
                    };
                    Versions.Add(ver);
                    SaveChanges();
                    updateDB = true;
                }
                else
                {
                    var dbVersion = Versions.Single(v => v.VersionType == DatabaseVersion.Constants && v.VersionString == UserConstants.ConstantsVersion);
                    if (dbVersion.Status == DatabaseVersion.Corrupted)
                    {   // try to update the database again - take a lock
                        TraceLog.TraceInfo("User database corrupted");
                        dbVersion.Status = me;
                        SaveChanges();
                        updateDB = true;
                    }
                }
                if (updateDB == false)
                {
                    TraceLog.TraceInfo(String.Format("User database version {0} is up to date", UserConstants.ConstantsVersion));
                    return(true);
                }
            }
            catch (Exception ex)
            {
                TraceLog.TraceException("Could not find database version", ex);
                return(false);
            }

            // update the default database values
            DatabaseVersion    version        = null;
            UserStorageContext versionContext = Storage.NewUserContext;

            try
            {   // verify that this unit of execution owns the update lock for the database version
                version = versionContext.Versions.Single(v => v.VersionType == DatabaseVersion.Constants && v.VersionString == UserConstants.ConstantsVersion);
                if (version.Status != me)
                {
                    return(true);
                }

                TraceLog.TraceInfo(String.Format("{0} updating User datatbase to version {1}", me, UserConstants.ConstantsVersion));

                // update existing action types, add new action types
                foreach (var entity in UserConstants.DefaultActionTypes())
                {
                    if (ActionTypes.Any(e => e.ActionTypeID == entity.ActionTypeID))
                    {
                        ActionTypes.Single(e => e.ActionTypeID == entity.ActionTypeID).Copy(entity);
                    }
                    else
                    {
                        ActionTypes.Add(entity);
                    }
                }
                SaveChanges();
                TraceLog.TraceInfo("Replaced action types");

                // update existing colors, add new colors
                foreach (var entity in UserConstants.DefaultColors())
                {
                    if (Colors.Any(e => e.ColorID == entity.ColorID))
                    {
                        Colors.Single(e => e.ColorID == entity.ColorID).Copy(entity);
                    }
                    else
                    {
                        Colors.Add(entity);
                    }
                }
                SaveChanges();
                TraceLog.TraceInfo("Replaced colors");

                // update existing permissions, add new permissions
                foreach (var entity in UserConstants.DefaultPermissions())
                {
                    if (Permissions.Any(e => e.PermissionID == entity.PermissionID))
                    {
                        Permissions.Single(e => e.PermissionID == entity.PermissionID).Copy(entity);
                    }
                    else
                    {
                        Permissions.Add(entity);
                    }
                }
                SaveChanges();
                TraceLog.TraceInfo("Replaced permissions");

                // update existing priorities, add new priorities
                foreach (var entity in UserConstants.DefaultPriorities())
                {
                    if (Priorities.Any(e => e.PriorityID == entity.PriorityID))
                    {
                        Priorities.Single(e => e.PriorityID == entity.PriorityID).Copy(entity);
                    }
                    else
                    {
                        Priorities.Add(entity);
                    }
                }
                SaveChanges();
                TraceLog.TraceInfo("Replaced priorities");

                // update existing or add new built-in users
                foreach (var user in UserConstants.DefaultUsers())
                {
                    if (Users.Any(u => u.ID == user.ID))
                    {
                        var existing = Users.Single(u => u.ID == user.ID);
                        existing.Name       = user.Name;
                        existing.Email      = user.Email;
                        existing.CreateDate = user.CreateDate;
                    }
                    else
                    {
                        Users.Add(user);
                    }
                }
                SaveChanges();
                TraceLog.TraceInfo("Replaced users");

                // update existing or add new built-in itemtypes and fields
                foreach (var itemType in UserConstants.DefaultItemTypes())
                {
                    if (ItemTypes.Any(it => it.ID == itemType.ID))
                    {
                        var existing = ItemTypes.Include("Fields").Single(it => it.ID == itemType.ID);
                        existing.Copy(itemType);
                        if (itemType.Fields == null)
                        {
                            continue;
                        }
                        foreach (var field in itemType.Fields)
                        {
                            if (existing.Fields.Any(f => f.ID == field.ID))
                            {
                                var existingField = existing.Fields.Single(f => f.ID == field.ID);
                                existingField.Copy(field);
                            }
                            else
                            {
                                existing.Fields.Add(field);
                            }
                        }
                    }
                    else
                    {
                        ItemTypes.Add(itemType);
                    }
                }
                SaveChanges();
                TraceLog.TraceInfo("Replaced item types and fields");

                // save the new version number
                version.Status = DatabaseVersion.OK;
                versionContext.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                TraceLog.TraceException("VersionConstants failed", ex);

                // mark the version as corrupted
                version.Status = DatabaseVersion.Corrupted;
                versionContext.SaveChanges();
                return(false);
            }
        }
예제 #19
0
 public static bool Contains(string version) => Versions.Any(v => v?.Id == version);