Exemple #1
0
        protected void PopulateMediaFromReader(IRecordsReader dr)
        {
            bool _hc = false;

            if (dr.GetInt("children") > 0)
            {
                _hc = true;
            }
            int?masterContentType = null;

            if (!dr.IsNull("masterContentType"))
            {
                masterContentType = dr.GetInt("masterContentType");
            }
            SetupMediaForTree(dr.GetGuid("uniqueId")
                              , dr.GetShort("level")
                              , dr.GetInt("parentId")
                              , dr.GetInt("nodeUser")
                              , dr.GetString("path")
                              , dr.GetString("text")
                              , dr.GetDateTime("createDate")
                              , dr.GetString("icon")
                              , _hc
                              , dr.GetString("alias")
                              , dr.GetString("thumbnail")
                              , dr.GetString("description")
                              , masterContentType
                              , dr.GetInt("contentTypeId"));
        }
Exemple #2
0
        public static Workflow CreateFromDataReader(IRecordsReader reader)
        {
            Workflow wf = new Workflow();

            wf.Id        = reader.GetGuid("id");
            wf.Name      = reader.GetString("name");
            wf.Form      = reader.GetGuid("form");
            wf.SortOrder = reader.GetInt("sortorder");
            wf.Active    = reader.GetBoolean("active");

            if (!reader.IsNull("executesOn"))
            {
                wf.ExecutesOn = (FormState)System.Enum.ToObject(typeof(FormState), reader.GetInt("executesOn"));
            }

            //if the type is null or does not exist in the collection, we should not initialize the workflow
            if (!reader.IsNull("type") && Umbraco.Forms.Core.Providers.WorkflowTypeProviderCollection.Instance.ContainsProvider(reader.GetGuid("type")))
            {
                wf.Type = Umbraco.Forms.Core.Providers.WorkflowTypeProviderCollection.Instance.GetProviderInstance(reader.GetGuid("type"));
            }
            else
            {
                wf.Active = false;
            }

            wf.Settings = new Dictionary <string, string>();

            return(wf);
        }
Exemple #3
0
        private void setupUser(int ID)
        {
            _id = ID;

            using (IRecordsReader dr = SqlHelper.ExecuteReader(
                       "Select userNoConsole, userDisabled, userType,startStructureID, startMediaId, userName,userLogin,userEmail,userDefaultPermissions, userLanguage, defaultToLiveEditing from umbracoUser where id = @id",
                       SqlHelper.CreateParameter("@id", ID)))
            {
                if (dr.Read())
                {
                    _userNoConsole = dr.GetBoolean("usernoconsole");
                    _userDisabled  = dr.GetBoolean("userDisabled");
                    _name          = dr.GetString("userName");
                    _loginname     = dr.GetString("userLogin");
                    _email         = dr.GetString("userEmail");
                    _language      = dr.GetString("userLanguage");
                    _startnodeid   = dr.GetInt("startStructureID");
                    if (!dr.IsNull("startMediaId"))
                    {
                        _startmediaid = dr.GetInt("startMediaID");
                    }
                    _usertype             = UserType.GetUserType(dr.GetShort("UserType"));
                    _defaultToLiveEditing = dr.GetBoolean("defaultToLiveEditing");
                }
                else
                {
                    throw new ArgumentException("No User exists with ID " + ID.ToString());
                }
            }
            _isInitialized = true;
        }
Exemple #4
0
 public PropertyType(int id)
 {
     using (IRecordsReader dr = SqlHelper.ExecuteReader(
                "Select mandatory, DataTypeId, tabId, ContentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id",
                SqlHelper.CreateParameter("@id", id)))
     {
         if (!dr.Read())
         {
             throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!");
         }
         _mandatory = dr.GetBoolean("mandatory");
         _id        = id;
         if (!dr.IsNull("tabId"))
         {
             _tabId = dr.GetInt("tabId");
         }
         _sortOrder        = dr.GetInt("sortOrder");
         _alias            = dr.GetString("alias");
         _name             = dr.GetString("Name");
         _validationRegExp = dr.GetString("validationRegExp");
         _DataTypeId       = dr.GetInt("DataTypeId");
         _contenttypeid    = dr.GetInt("contentTypeId");
         _description      = dr.GetString("description");
     }
 }
        /// <summary>
        /// Initializes the user node permissions
        /// </summary>
        public void initCruds()
        {
            if (!_isInitialized)
            {
                setupUser(_id);
            }

            // clear cruds
            System.Web.HttpContext.Current.Application.Lock();
            _cruds.Clear();
            System.Web.HttpContext.Current.Application.UnLock();

            using (IRecordsReader dr = SqlHelper.ExecuteReader("select * from umbracoUser2NodePermission where userId = @userId order by nodeId", SqlHelper.CreateParameter("@userId", this.Id)))
            {
                //	int currentId = -1;
                while (dr.Read())
                {
                    if (!_cruds.ContainsKey(dr.GetInt("nodeId")))
                    {
                        _cruds.Add(dr.GetInt("nodeId"), String.Empty);
                    }

                    _cruds[dr.GetInt("nodeId")] += dr.GetString("permission");
                }
            }
            _crudsInitialized = true;
        }
        //public CmsNode GetNodeById(Guid uniqueId)
        //{
        //    CmsNode cmsNode;
        //    var id = SqlHelper.ExecuteScalar<int>("SELECT id FROM umbracoNode WHERE uniqueID = @uniqueId", SqlHelper.CreateParameter("@uniqueId", uniqueId));
        //    using (IRecordsReader dr = SqlHelper.ExecuteReader(m_SQLSingle,
        //            SqlHelper.CreateParameter("@id", id)))
        //    {
        //        if (dr.Read() || dr.IsNull("uniqueID"))
        //        {
        //            cmsNode = new CmsNode
        //                {
        //                    UniqueId = dr.GetGuid("uniqueID"),
        //                    NodeObjectType = dr.GetGuid("nodeObjectType"),
        //                    ContentTypeId = dr.GetInt("contentTypeId"),
        //                    Level = dr.GetShort("level"),
        //                    Path = dr.GetString("path"),
        //                    ParentId = dr.GetInt("parentId"),
        //                    Text = dr.GetString("text"),
        //                    SortOrder = dr.GetInt("sortOrder"),
        //                    UserId = dr.GetInt("nodeUser"),
        //                    CreateDate = dr.GetDateTime("createDate"),
        //                    IsTrashed = dr.GetBoolean("trashed")
        //                };
        //        }
        //        else
        //        {
        //            throw new ArgumentException(string.Format("No node exists with id '{0}' ({1})", id, uniqueId));
        //        }
        //    }

        //    return cmsNode;
        //}

        public IEnumerable <T> GetNodesByIds <T>(Guid[] uniqueIds) where T : CmsNode, new()
        {
            var cmsNodes = new List <T>();

            // TODO: parameterize this the "right" way to prevent future sql injection
            var strUIds = string.Format("'{0}'", string.Join("','", uniqueIds));

            var ids = new List <int>();

            using (IRecordsReader reader = SqlHelper.ExecuteReader(string.Format("SELECT id FROM umbracoNode WHERE uniqueID in ({0})", strUIds)))
            {
                while (reader.Read())
                {
                    ids.Add(reader.GetInt("id"));
                }
            }

            var strIds = string.Join(",", ids);

            using (IRecordsReader dr = SqlHelper.ExecuteReader(string.Format(m_SQMultiple, strIds)))
            {
                while (dr.Read())
                {
                    cmsNodes.Add(new T
                    {
                        UniqueId       = dr.GetGuid("uniqueID"),
                        NodeObjectType = dr.GetGuid("nodeObjectType"),
                        ContentTypeId  = dr.GetInt("contentTypeId"),
                        Level          = dr.GetShort("level"),
                        Path           = dr.GetString("path"),
                        ParentId       = dr.GetInt("parentId"),
                        Text           = dr.GetString("text"),
                        SortOrder      = dr.GetInt("sortOrder"),
                        UserId         = dr.GetInt("nodeUser"),
                        CreateDate     = dr.GetDateTime("createDate"),
                        IsTrashed      = dr.GetBoolean("trashed")
                    });
                }
            }

            if (typeof(T) == typeof(DocType))
            {
                // Fill out property data
                foreach (var node in cmsNodes)
                {
                    var docType = node as DocType;
                    if (docType != null)
                    {
                        docType.Properties = GetPropertyTypes(node).ToList();
                    }
                }
            }

            return(cmsNodes);
        }
Exemple #7
0
 private void PopulateTaskFromReader(IRecordsReader dr)
 {
     _id        = dr.GetInt("id");
     Type       = new TaskType((int)dr.GetByte("taskTypeId"));
     Node       = new CMSNode(dr.GetInt("nodeId"));
     ParentUser = User.GetUser(dr.GetInt("parentUserId"));
     User       = User.GetUser(dr.GetInt("userId"));
     Date       = dr.GetDateTime("DateTime");
     Comment    = dr.GetString("comment");
     Closed     = dr.GetBoolean("closed");
 }
 protected void PopulateDocumentTypeNodeFromReader(IRecordsReader dr)
 {
     if (!dr.IsNull("templateNodeId"))
     {
         _templateIds.Add(dr.GetInt("templateNodeId"));
         if (!dr.IsNull("IsDefault"))
         {
             if (dr.GetBoolean("IsDefault"))
             {
                 _defaultTemplate = dr.GetInt("templateNodeId");
             }
         }
     }
 }
Exemple #9
0
 private void InitDomain(int id)
 {
     using (IRecordsReader dr = SqlHelper.ExecuteReader(
                "select domainDefaultLanguage, domainRootStructureID, domainName from umbracoDomains where id = @ID",
                SqlHelper.CreateParameter("@ID", id)))
     {
         if (dr.Read())
         {
             _id       = id;
             _language = new Language(dr.GetInt("domainDefaultLanguage"));
             _name     = dr.GetString("domainName");
             _root     = dr.GetInt("domainRootStructureID");
         }
     }
 }
Exemple #10
0
        public static Record CreateFromDataReader(IRecordsReader reader)
        {
            Record record = Create();

            record.Id            = reader.GetGuid("Id");
            record.Form          = reader.GetGuid("Form");
            record.Created       = reader.GetDateTime("Created");
            record.Updated       = reader.GetDateTime("Updated");
            record.State         = reader.GetInt("State");
            record.currentPage   = reader.GetGuid("currentPage");
            record.umbracoPageId = reader.GetInt("umbracoPageId");
            record.IP            = reader.GetString("IP");
            record.MemberKey     = reader.GetString("MemberKey");
            return(record);
        }
Exemple #11
0
        /// <summary>
        /// Reads all items from the database and stores in local cache
        /// </summary>
        private static void EnsureCache()
        {
            if (!_cacheIsEnsured)
            {
                lock (Locker)
                {
                    if (!_cacheIsEnsured)
                    {
                        using (IRecordsReader dr = SqlHelper.ExecuteReader("Select pk, id, [key], parent from cmsDictionary"))
                        {
                            while (dr.Read())
                            {
                                //create new dictionaryitem object and put in cache
                                var item = new DictionaryItem(dr.GetInt("pk"),
                                                              dr.GetString("key"),
                                                              dr.GetGuid("id"),
                                                              dr.GetGuid("parent"));

                                DictionaryItems.TryAdd(item.key, item);
                            }
                        }

                        _cacheIsEnsured = true;
                    }
                }
            }
        }
Exemple #12
0
        internal static List <Domain> GetDomains()
        {
            return(Cache.GetCacheItem <List <Domain> >("UmbracoDomainList", getDomainsSyncLock, TimeSpan.FromMinutes(30),
                                                       delegate
            {
                List <Domain> result = new List <Domain>();
                using (IRecordsReader dr = SqlHelper.ExecuteReader(
                           "select id, domainName from umbracoDomains"))
                {
                    while (dr.Read())
                    {
                        string domainName = dr.GetString("domainName");
                        int domainId = dr.GetInt("id");

                        if (result.Find(delegate(Domain d) { return d.Name == domainName; }) == null)
                        {
                            result.Add(new Domain(domainId));
                        }
                        else
                        {
                            Log.Add(LogTypes.Error, User.GetUser(0), -1,
                                    string.Format("Domain already exists in list ({0})", domainName));
                        }
                    }
                }
                return result;
            }));
        }
        /// <summary>
        /// Delete all relations using the content node for a given RelationType
        /// </summary>
        /// <param name="relationType"></param>
        /// <param name="contentNodeId"></param>
        /// <param name="reverseIndexing"></param>
        /// <param name="instanceIdentifier">NOT USED ATM</param>
        private static void DeleteRelations(RelationType relationType, int contentNodeId, bool reverseIndexing, string instanceIdentifier)
        {
            //if relationType is bi-directional or a reverse index then we can't get at the relations via the API, so using SQL
            string getRelationsSql = "SELECT id FROM umbracoRelation WHERE relType = " + relationType.Id.ToString() + " AND ";

            if (reverseIndexing || relationType.Dual)
            {
                getRelationsSql += "childId = " + contentNodeId.ToString();
            }
            if (relationType.Dual)             // need to return relations where content node id is used on both sides
            {
                getRelationsSql += " OR ";
            }
            if (!reverseIndexing || relationType.Dual)
            {
                getRelationsSql += "parentId = " + contentNodeId.ToString();
            }

            getRelationsSql += " AND comment = '" + instanceIdentifier + "'";

            using (IRecordsReader relations = uQuery.SqlHelper.ExecuteReader(getRelationsSql))
            {
                //clear data
                Relation relation;
                while (relations.Read())
                {
                    relation = new Relation(relations.GetInt("id"));

                    // TODO: [HR] check to see if an instance identifier is used
                    relation.Delete();
                }
            }
        }
Exemple #14
0
        private void CleanPropertiesOnDeletion(int contentTypeId)
        {
            // first delete from all master document types
            //TODO: Verify no endless loops with mixins
            DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentTypes.Contains(contentTypeId)).ForEach(
                dt => CleanPropertiesOnDeletion(dt.Id));

            //Initially Content.getContentOfContentType() was called, but because this doesn't include members we resort to sql lookups and deletes
            var            tmp = new List <int>();
            IRecordsReader dr  = SqlHelper.ExecuteReader("SELECT nodeId FROM cmsContent INNER JOIN umbracoNode ON cmsContent.nodeId = umbracoNode.id WHERE ContentType = " + contentTypeId + " ORDER BY umbracoNode.text ");

            while (dr.Read())
            {
                tmp.Add(dr.GetInt("nodeId"));
            }
            dr.Close();

            foreach (var contentId in tmp)
            {
                SqlHelper.ExecuteNonQuery("DELETE FROM cmsPropertyData WHERE PropertyTypeId =" + this.Id + " AND contentNodeId = " + contentId);
            }

            // invalidate content type cache
            ContentType.FlushFromCache(contentTypeId);
        }
Exemple #15
0
        private static List <Relation> GetRelations(string alias, string sort, int parentId, int number)
        {
            List <Relation> retval    = new List <Relation>();
            ISqlHelper      sqlhelper = umbraco.BusinessLogic.Application.SqlHelper;

            IRecordsReader rr = sqlhelper.ExecuteReader(

                string.Format(@"
                SELECT TOP {0} umbracoRelation.id
                FROM umbracoRelation
                INNER JOIN umbracoRelationType ON umbracoRelationType.id = umbracoRelation.relType AND umbracoRelationType.alias = @alias
                where parentId = @parent
                ORDER BY datetime {1}                
                ", number, sort)

                ,
                sqlhelper.CreateParameter("@parent", parentId),
                sqlhelper.CreateParameter("@alias", alias)
                );

            while (rr.Read())
            {
                retval.Add(new Relation(rr.GetInt("id")));
            }
            rr.Close();
            rr.Dispose();

            return(retval);
        }
Exemple #16
0
        /// <summary>
        /// Populates the global hash table with the data from the database.
        /// </summary>
        private static void ensureData()
        {
            if (!m_IsInitialize)
            {
                lock (m_Locker)
                {
                    //double check
                    if (!m_IsInitialize)
                    {
                        // load all data
                        using (IRecordsReader dr = SqlHelper.ExecuteReader("Select LanguageId, UniqueId,[value] from cmsLanguageText order by UniqueId"))
                        {
                            while (dr.Read())
                            {
                                int    LanguageId = dr.GetInt("LanguageId");
                                Guid   UniqueId   = dr.GetGuid("UniqueId");
                                string text       = dr.GetString("value");

                                updateCache(LanguageId, UniqueId, text);
                            }
                        }
                        m_IsInitialize = true;
                    }
                }
            }
        }
Exemple #17
0
        public static List <LogItem> ConvertIRecordsReader(IRecordsReader reader)
        {
            var items = new List <LogItem>();

            while (reader.Read())
            {
                items.Add(new LogItem(
                              reader.GetInt("userId"),
                              reader.GetInt("nodeId"),
                              reader.GetDateTime("DateStamp"),
                              ConvertLogHeader(reader.GetString("logHeader")),
                              reader.GetString("logComment")));
            }

            return(items);
        }
        public static IEnumerable <Document> GetDocumentsWithTags(string tags)
        {
            var    docs = new List <Document>();
            string sql  = @"SELECT DISTINCT cmsTagRelationShip.nodeid from cmsTagRelationShip
                            INNER JOIN cmsTags ON cmsTagRelationShip.tagid = cmsTags.id 
                            INNER JOIN umbracoNode ON cmsTagRelationShip.nodeId = umbracoNode.id
                            WHERE (cmsTags.tag IN ({0})) AND nodeObjectType=@nodeType";

            using (var sqlHelper = Application.SqlHelper)
                using (IRecordsReader rr = sqlHelper.ExecuteReader(string.Format(sql, GetSqlStringArray(tags)),
                                                                   sqlHelper.CreateParameter("@nodeType", Document._objectType)))
                {
                    while (rr.Read())
                    {
                        Document cnode = new Document(rr.GetInt("nodeid"));

                        if (cnode.Published)
                        {
                            docs.Add(cnode);
                        }
                    }
                }

            return(docs);
        }
        public List <object> GetRecordFieldValues(RecordField rf)
        {
            string        sql = string.Format("SELECT * FROM UFRecordData{0} where [Key] = @key ORDER BY Id ASC", rf.DataTypeAlias);
            List <object> l   = new List <object>();

            IRecordsReader rr = sqlHelper.ExecuteReader(sql, sqlHelper.CreateParameter("@key", rf.Key));

            while (rr.Read())
            {
                switch (rf.DataType)
                {
                case FieldDataType.String:
                case FieldDataType.LongString:
                    l.Add(rr.GetString("Value"));
                    break;

                case FieldDataType.Integer:
                    l.Add(rr.GetInt("Value"));
                    break;

                case FieldDataType.DateTime:
                    l.Add(rr.GetDateTime("Value"));
                    break;

                case FieldDataType.Bit:
                    l.Add(rr.GetBoolean("Value"));
                    break;
                }
            }

            rr.Dispose();

            return(l);
        }
Exemple #20
0
        private void PopulateMacroInfo(IRecordsReader dr)
        {
            _useInEditor   = dr.GetBoolean("macroUseInEditor");
            _refreshRate   = dr.GetInt("macroRefreshRate");
            _alias         = dr.GetString("macroAlias");
            _id            = dr.GetInt("id");
            _name          = dr.GetString("macroName");
            _assembly      = dr.GetString("macroScriptAssembly");
            _type          = dr.GetString("macroScriptType");
            _xslt          = dr.GetString("macroXSLT");
            _scriptingFile = dr.GetString("macroPython");

            _cacheByPage       = dr.GetBoolean("macroCacheByPage");
            _cachePersonalized = dr.GetBoolean("macroCachePersonalized");
            _renderContent     = !dr.GetBoolean("macroDontRender");
        }
Exemple #21
0
        protected override void setupNode()
        {
            base.setupNode();

            IRecordsReader dr      = SqlHelper.ExecuteReader("Select alias,design,master from cmsTemplate where nodeId = " + this.Id);
            bool           hasRows = dr.Read();

            if (hasRows)
            {
                _alias  = dr.GetString("alias");
                _design = dr.GetString("design");
                //set the master template to zero if it's null
                _mastertemplate = dr.IsNull("master") ? 0 : dr.GetInt("master");
            }
            dr.Close();

            if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc && ViewHelper.ViewExists(this))
            {
                _design = ViewHelper.GetFileContents(this);
            }
            else
            {
                _design = MasterPageHelper.GetFileContents(this);
            }
        }
Exemple #22
0
        public static List <Subscribtion> Subscribers(int topicId)
        {
            List <Subscribtion> l  = new List <Subscribtion>();
            IRecordsReader      rr = Data.SqlHelper.ExecuteReader("SELECT * from forumTopicSubscribers where topicid = @topicId",
                                                                  Data.SqlHelper.CreateParameter("@topicId", topicId));

            while (rr.Read())
            {
                Subscribtion s = new Subscribtion();
                s.MemberId = rr.GetInt("memberId");
                s.TopicId  = rr.GetInt("topicId");
                s.Date     = rr.GetDateTime("date");
                l.Add(s);
            }

            return(l);
        }
Exemple #23
0
        /// <summary>
        /// Gets the pre values collection.
        /// </summary>
        /// <param name="DataTypeId">The data type id.</param>
        /// <returns></returns>
        public static SortedList GetPreValues(int DataTypeId)
        {
            SortedList     retval = new SortedList();
            IRecordsReader dr     = SqlHelper.ExecuteReader(
                "Select id, sortorder, [value] from cmsDataTypePreValues where DataTypeNodeId = @dataTypeId order by sortorder",
                SqlHelper.CreateParameter("@dataTypeId", DataTypeId));

            int counter = 0;

            while (dr.Read())
            {
                retval.Add(counter, new PreValue(dr.GetInt("id"), dr.GetInt("sortorder"), dr.GetString("value")));
                counter++;
            }
            dr.Close();
            return(retval);
        }
        /// <summary>
        /// Returns the permissions for a node
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static IEnumerable <UserTypePermissions> GetNodePermissions(CMSNode node)
        {
            var items = new List <UserTypePermissions>();

            using (IRecordsReader dr = SqlHelper.ExecuteReader("select * from UserGroupPermissions_UserType2NodePermission where nodeId = @nodeId order by nodeId", SqlHelper.CreateParameter("@nodeId", node.Id)))
            {
                while (dr.Read())
                {
                    items.Add(new UserTypePermissions()
                    {
                        NodeId       = dr.GetInt("nodeId"),
                        PermissionId = Convert.ToChar(dr.GetString("permission")),
                        UserTypeId   = dr.GetInt("userTypeId")
                    });
                }
            }
            return(items);
        }
Exemple #25
0
 private void PopulateFromReader(IRecordsReader dr)
 {
     this._id   = dr.GetInt("id");
     this._dual = dr.GetBoolean("dual");
     //this._parentObjectType = dr.GetGuid("parentObjectType");
     //this._childObjectType = dr.GetGuid("childObjectType");
     this._name  = dr.GetString("name");
     this._alias = dr.GetString("alias");
 }
Exemple #26
0
        /// <summary>
        /// Returns the permissions for a user
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static IEnumerable <Permission> GetUserPermissions(User user)
        {
            var items = new List <Permission>();

            using (IRecordsReader dr = SqlHelper.ExecuteReader("select * from umbracoUser2NodePermission where userId = @userId order by nodeId", SqlHelper.CreateParameter("@userId", user.Id)))
            {
                while (dr.Read())
                {
                    items.Add(new Permission()
                    {
                        NodeId       = dr.GetInt("nodeId"),
                        PermissionId = Convert.ToChar(dr.GetString("permission")),
                        UserId       = dr.GetInt("userId")
                    });
                }
            }
            return(items);
        }
Exemple #27
0
        private static Company FromReader(Company c, IRecordsReader rr)
        {
            c.Id       = rr.GetInt("id");
            c.Category = rr.GetString("category");
            c.Name     = rr.GetString("name");
            c.Symbol   = rr.GetString("symbol");

            return(c);
        }
Exemple #28
0
        /// <summary>
        /// Returns the notifications for a node
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static IEnumerable <Notification> GetNodeNotifications(CMSNode node)
        {
            var items = new List <Notification>();

            using (IRecordsReader dr = SqlHelper.ExecuteReader("select * from umbracoUser2NodeNotify where nodeId = @nodeId order by nodeId", SqlHelper.CreateParameter("@nodeId", node.Id)))
            {
                while (dr.Read())
                {
                    items.Add(new Notification()
                    {
                        NodeId   = dr.GetInt("nodeId"),
                        ActionId = Convert.ToChar(dr.GetString("action")),
                        UserId   = dr.GetInt("userId")
                    });
                }
            }
            return(items);
        }
Exemple #29
0
 public Relation(int Id)
 {
     using (IRecordsReader dr = SqlHelper.ExecuteReader("select * from umbracoRelation where id = @id", SqlHelper.CreateParameter("@id", Id)))
     {
         if (dr.Read())
         {
             this._id         = dr.GetInt("id");
             this._parentNode = new CMSNode(dr.GetInt("parentId"));
             this._childNode  = new CMSNode(dr.GetInt("childId"));
             this._relType    = RelationType.GetById(dr.GetInt("relType"));
             this._comment    = dr.GetString("comment");
             this._datetime   = dr.GetDateTime("datetime");
         }
         else
         {
             throw new ArgumentException("No relation found for id " + Id.ToString());
         }
     }
 }
Exemple #30
0
        private static IEnumerable <Tag> ConvertSqlToTags(string sql, params IParameter[] param)
        {
            List <Tag> tags = new List <Tag>();

            using (IRecordsReader rr = SqlHelper.ExecuteReader(sql, param))
            {
                while (rr.Read())
                {
                    tags.Add(new Tag(
                                 rr.GetInt("id"),
                                 rr.GetString("tag"),
                                 rr.GetString("group"),
                                 rr.GetInt("nodeCount")));
                }
            }


            return(tags);
        }
Exemple #31
0
 protected void PopulateDocumentTypeNodeFromReader(IRecordsReader dr)
 {
     if (!dr.IsNull("templateNodeId"))
     {
         _templateIds.Add(dr.GetInt("templateNodeId"));
         if (!dr.IsNull("IsDefault"))
         {
             if (dr.GetBoolean("IsDefault"))
             {
                 _defaultTemplate = dr.GetInt("templateNodeId");
             }
         }
     }
 }
Exemple #32
0
        protected void PopulateDocumentFromReader(IRecordsReader dr)
        {
            bool _hc = false;

            if (dr.GetInt("children") > 0)
                _hc = true;

            int? masterContentType = null;

            if (!dr.IsNull("masterContentType"))
                masterContentType = dr.GetInt("masterContentType");

            SetupDocumentForTree(dr.GetGuid("uniqueId")
                , dr.GetShort("level")
                , dr.GetInt("parentId")
                , dr.GetInt("nodeUser")
                , dr.GetInt("documentUser")
                , (dr.GetInt("isPublished") == 1)
                , dr.GetString("path")
                , dr.GetString("text")
                , dr.GetDateTime("createDate")
                , dr.GetDateTime("updateDate")
                , dr.GetDateTime("versionDate")
                , dr.GetString("icon")
                , _hc
                , dr.GetString("alias")
                , dr.GetString("thumbnail")
                , dr.GetString("description")
                , masterContentType
                , dr.GetInt("contentTypeId")
                , dr.GetInt("templateId"));
        }
Exemple #33
0
 private void PopulateTaskFromReader(IRecordsReader dr)
 {
     _id = dr.GetInt("id");
     Type = new TaskType((int)dr.GetByte("taskTypeId"));
     Node = new CMSNode(dr.GetInt("nodeId"));
     ParentUser = User.GetUser(dr.GetInt("parentUserId"));
     User = User.GetUser(dr.GetInt("userId"));
     Date = dr.GetDateTime("DateTime");
     Comment = dr.GetString("comment");
     Closed = dr.GetBoolean("closed");
 } 
Exemple #34
0
        protected void PopulateContentTypeNodeFromReader(IRecordsReader dr)
        {
            _alias = dr.GetString("Alias");
            _iconurl = dr.GetString("icon");
            if (!dr.IsNull("masterContentType"))
                m_masterContentType = dr.GetInt("masterContentType");

            if (!dr.IsNull("thumbnail"))
                _thumbnail = dr.GetString("thumbnail");
            if (!dr.IsNull("description"))
                _description = dr.GetString("description");
        }
Exemple #35
0
        protected void PopulateMediaFromReader(IRecordsReader dr)
        {
            var hc = dr.GetInt("children") > 0;

            SetupMediaForTree(dr.GetGuid("uniqueId")
                , dr.GetShort("level")
                , dr.GetInt("parentId")
                , dr.GetInt("nodeUser")
                , dr.GetString("path")
                , dr.GetString("text")
                , dr.GetDateTime("createDate")
                , dr.GetString("icon")
                , hc
                , dr.GetString("alias")
                , dr.GetString("thumbnail")
                , dr.GetString("description")
                , null
                , dr.GetInt("contentTypeId")
                , dr.GetBoolean("isContainer"));
        } 
Exemple #36
0
        protected void PopulateDocumentFromReader(IRecordsReader dr)
        {
            var hc = dr.GetInt("children") > 0;

            SetupDocumentForTree(dr.GetGuid("uniqueId")
                , dr.GetShort("level")
                , dr.GetInt("parentId")
                , dr.GetInt("nodeUser")
                , dr.GetInt("documentUser")
                , !dr.GetBoolean("trashed") && (dr.GetInt("isPublished") == 1) //set published... double check trashed property
                , dr.GetString("path")
                , dr.GetString("text")
                , dr.GetDateTime("createDate")
                , dr.GetDateTime("updateDate")
                , dr.GetDateTime("versionDate")
                , dr.GetString("icon")
                , hc
                , dr.GetString("alias")
                , dr.GetString("thumbnail")
                , dr.GetString("description")
                     , null
                , dr.GetInt("contentTypeId")
                     , dr.GetInt("templateId")
                     , dr.GetBoolean("isContainer"));

            if (!dr.IsNull("releaseDate"))
                _release = dr.GetDateTime("releaseDate");
            if (!dr.IsNull("expireDate"))
                _expire = dr.GetDateTime("expireDate");
        }
Exemple #37
0
        public static bool TryGetColumnInt32(IRecordsReader reader, string columnName, out int value)
        {
            if (reader.ContainsField(columnName) && !reader.IsNull(columnName))
            {
                value = reader.GetInt(columnName);
                return true;
            }

            value = -1;
            return false;
        }
Exemple #38
0
        public static List<LogItem> ConvertIRecordsReader(IRecordsReader reader)
        {
            var items = new List<LogItem>();
            while (reader.Read())
            {
                items.Add(new LogItem(
                    reader.GetInt("userId"),
                    reader.GetInt("nodeId"),
                    reader.GetDateTime("DateStamp"),
                    ConvertLogHeader(reader.GetString("logHeader")),
                    reader.GetString("logComment")));
            }

            return items;

        }
Exemple #39
0
        protected void PopulateMemberFromReader(IRecordsReader dr)
        {

            SetupNodeForTree(dr.GetGuid("uniqueId"),
                _objectType, dr.GetShort("level"),
                dr.GetInt("parentId"),
                dr.GetInt("nodeUser"),
                dr.GetString("path"),
                dr.GetString("text"),
                dr.GetDateTime("createDate"), false);

            if (!dr.IsNull("Email"))
                m_Email = dr.GetString("Email");
            m_LoginName = dr.GetString("LoginName");
            m_Password = dr.GetString("Password");

        }
 private void PopulateFromReader(IRecordsReader dr)
 {
     this._id = dr.GetInt("id");
     this._dual = dr.GetBoolean("dual");
     //this._parentObjectType = dr.GetGuid("parentObjectType");
     //this._childObjectType = dr.GetGuid("childObjectType");
     this._name = dr.GetString("name");
     this._alias = dr.GetString("alias");
 }
        private static XPathNodeIterator CommentsToXml(IRecordsReader rr)
        {
            XmlDocument xd = new XmlDocument();

            XmlNode x = umbraco.xmlHelper.addTextNode(xd, "comments", "");

            while (rr.Read())
            {
                XmlNode c = xd.CreateElement("comment");

                c.Attributes.Append(umbraco.xmlHelper.addAttribute(xd, "id", rr.GetInt("id").ToString()));
                c.Attributes.Append(umbraco.xmlHelper.addAttribute(xd, "nodeid", rr.GetInt("nodeid").ToString()));
                c.Attributes.Append(umbraco.xmlHelper.addAttribute(xd, "created", rr.GetDateTime("created").ToString()));

                c.AppendChild(umbraco.xmlHelper.addCDataNode(xd, "name", rr.GetString("name")));
                c.AppendChild(umbraco.xmlHelper.addCDataNode(xd, "email", rr.GetString("email")));
                c.AppendChild(umbraco.xmlHelper.addCDataNode(xd, "website", rr.GetString("website")));
                c.AppendChild(umbraco.xmlHelper.addCDataNode(xd, "message", rr.GetString("comment")));

                x.AppendChild(c);
            }

            xd.AppendChild(x);
            rr.Close();
            return xd.CreateNavigator().Select(".");
        }
Exemple #42
0
        private void PopulateMacroInfo(IRecordsReader dr)
        {
            _useInEditor = dr.GetBoolean("macroUseInEditor");
            _refreshRate = dr.GetInt("macroRefreshRate");
            _alias = dr.GetString("macroAlias");
            _id = dr.GetInt("id");
            _name = dr.GetString("macroName");
            _assembly = dr.GetString("macroScriptAssembly");
            _type = dr.GetString("macroScriptType");
            _xslt = dr.GetString("macroXSLT");
            _scriptingFile = dr.GetString("macroPython");

            _cacheByPage = dr.GetBoolean("macroCacheByPage");
            _cachePersonalized = dr.GetBoolean("macroCachePersonalized");
            _renderContent = !dr.GetBoolean("macroDontRender");
        }
Exemple #43
0
        private static Company FromReader(Company c, IRecordsReader rr)
        {
            c.Id = rr.GetInt("id");
            c.Category = rr.GetString("category");
            c.Name = rr.GetString("name");
            c.Symbol = rr.GetString("symbol");

            return c;
        }