예제 #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 static List <UmbracoVersion> GetVersionsFromString(string p)
        {
            var umbracoVersions = new List <UmbracoVersion>();

            foreach (var ver in p.Split(','))
            {
                if (UmbracoVersion.AvailableVersions().ContainsKey(ver))
                {
                    umbracoVersions.Add(UmbracoVersion.AvailableVersions()[ver]);
                }
            }

            return(umbracoVersions);
        }
예제 #3
0
        /// <summary>
        /// Gets all wiki files for all nodes
        /// </summary>
        /// <returns></returns>
        public static Dictionary <int, IEnumerable <WikiFile> > CurrentFiles(IEnumerable <int> nodeIds)
        {
            var wikiFiles = new Dictionary <int, List <WikiFile> >();

            //we can only have 2000 (actually 2100) SQL parameters used at once, so we need to group them
            var nodeBatches = nodeIds.InGroupsOf(2000);

            foreach (var nodeBatch in nodeBatches)
            {
                foreach (var result in ApplicationContext.Current.DatabaseContext.Database.Query <dynamic>("SELECT * FROM wikiFiles WHERE nodeId IN (@nodeIds)", new { nodeIds = nodeBatch }))
                {
                    var file = new WikiFile
                    {
                        Id                   = result.id,
                        Path                 = result.path,
                        Name                 = result.name,
                        FileType             = result.type,
                        RemovedBy            = result.removedBy,
                        CreatedBy            = result.createdBy,
                        NodeVersion          = result.version,
                        NodeId               = result.nodeId,
                        CreateDate           = result.createDate,
                        DotNetVersion        = result.dotNetVersion,
                        Downloads            = result.downloads,
                        Archived             = result.archived,
                        Verified             = result.verified,
                        Versions             = GetVersionsFromString(result.umbracoVersion),
                        MinimumVersionStrict = result.minimumVersionStrict
                    };

                    file.Version = file.Versions.Any()
                        ? GetVersionsFromString(result.umbracoVersion)[0]
                        : UmbracoVersion.DefaultVersion();

                    if (wikiFiles.ContainsKey(result.nodeId))
                    {
                        var list = wikiFiles[result.nodeId];
                        list.Add(file);
                    }
                    else
                    {
                        wikiFiles.Add(result.nodeId, new List <WikiFile>(new[] { file }));
                    }
                }
            }

            return(wikiFiles.ToDictionary(x => x.Key, x => (IEnumerable <WikiFile>)x.Value));
        }
예제 #4
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();
                 }
             }
         }
 }