当前位置: 首页>>代码示例>>C#>>正文


C# BusinessLogic.User类代码示例

本文整理汇总了C#中umbraco.BusinessLogic.User的典型用法代码示例。如果您正苦于以下问题:C# User类的具体用法?C# User怎么用?C# User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


User类属于umbraco.BusinessLogic命名空间,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MarkAsSolution

        public static string MarkAsSolution(string pageId)
        {
            if (MembershipHelper.IsAuthenticated())
            {
                var m = Member.GetCurrentMember();
                var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(pageId)));
                if (forumPost != null)
                {
                    var forumTopic = _mapper.MapForumTopic(new Node(forumPost.ParentId.ToInt32()));
                    // If this current member id doesn't own the topic then ignore, also 
                    // if the topic is already solved then ignore.
                    if (m.Id == forumTopic.Owner.MemberId && !forumTopic.IsSolved)
                    {
                        // Get a user to save both documents with
                        var usr = new User(0);

                        // First mark the post as the solution
                        var p = new Document(forumPost.Id);
                        p.getProperty("forumPostIsSolution").Value = 1;
                        p.Publish(usr);
                        library.UpdateDocumentCache(p.Id);

                        // Now update the topic
                        var t = new Document(forumTopic.Id);
                        t.getProperty("forumTopicSolved").Value = 1;
                        t.Publish(usr);
                        library.UpdateDocumentCache(t.Id);

                        return library.GetDictionaryItem("Updated");
                    } 
                }
            }
            return library.GetDictionaryItem("Error");
        } 
开发者ID:elrute,项目名称:Triphulcas,代码行数:34,代码来源:nForumBaseExtensions.cs

示例2: PerformChangePassword

        /// <summary>
        /// Processes a request to update the password for a membership user.
        /// </summary>
        /// <param name="username">The user to update the password for.</param>
        /// <param name="oldPassword">The current password for the specified user.</param>
        /// <param name="newPassword">The new password for the specified user.</param>
        /// <returns>
        /// true if the password was updated successfully; otherwise, false.
        /// </returns>
        /// <remarks>
        /// During installation the application will not be configured, if this is the case and the 'default' password 
        /// is stored in the database then we will validate the user - this will allow for an admin password reset if required
        /// </remarks>
        protected override bool PerformChangePassword(string username, string oldPassword, string newPassword)
        {


            if (ApplicationContext.Current.IsConfigured == false && oldPassword == "default"
                || ValidateUser(username, oldPassword))
            {
                var args = new ValidatePasswordEventArgs(username, newPassword, false);
                OnValidatingPassword(args);

                if (args.Cancel)
                {
                    if (args.FailureInformation != null)
                        throw args.FailureInformation;
                    throw new MembershipPasswordException("Change password canceled due to password validation failure.");
                }

                var user = new User(username);
                //encrypt/hash the new one
                string salt;
                var encodedPassword = EncryptOrHashNewPassword(newPassword, out salt);

                //Yes, it's true, this actually makes a db call to set the password
                user.Password = FormatPasswordForStorage(encodedPassword, salt);
                //call this just for fun.
                user.Save();

                return true;    
            }

            return false;

        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:46,代码来源:UsersMembershipProvider.cs

示例3: BtnMoveClick

        protected void BtnMoveClick(object sender, EventArgs e)
        {
            if (Category.Id != ddlCategories.SelectedValue.ToInt32())
            {
                // Get the document you will move by its ID
                var doc = new Document(Topic.Id);

                // Create a user we can use for both
                var user = new User(0);

                // The new parent ID
                var newParentId = ddlCategories.SelectedValue.ToInt32();

                // Now update the topic parent category ID
                doc.getProperty("forumTopicParentCategoryID").Value = newParentId;

                // publish application node
                doc.Publish(user);

                // Move the document the new parent
                doc.Move(newParentId);

                // update the document cache so its available in the XML
                umbraco.library.UpdateDocumentCache(doc.Id);

                // Redirect and show message
                Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicHasBeenMovedText")));
            }
            else
            {
                // Can't move as they have selected the category that the topic is already in
                Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicAlreadyInThisCategory")));
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:34,代码来源:ForumMoveTopic.ascx.cs

示例4: MakeNew

        internal static void MakeNew(User user, IEnumerable<CMSNode> nodes, char permissionKey, bool raiseEvents)
        {
            var asArray = nodes.ToArray();
            foreach (var node in asArray)
            {
                var parameters = new[] { SqlHelper.CreateParameter("@userId", user.Id),
                                                         SqlHelper.CreateParameter("@nodeId", node.Id),
                                                         SqlHelper.CreateParameter("@permission", permissionKey.ToString()) };

                // Method is synchronized so exists remains consistent (avoiding race condition)
                var exists = SqlHelper.ExecuteScalar<int>(
                    "SELECT COUNT(userId) FROM umbracoUser2nodePermission WHERE userId = @userId AND nodeId = @nodeId AND permission = @permission",
                    parameters) > 0;

                if (exists) return;

                SqlHelper.ExecuteNonQuery(
                    "INSERT INTO umbracoUser2nodePermission (userId, nodeId, permission) VALUES (@userId, @nodeId, @permission)",
                    parameters);
            }

            if (raiseEvents)
            {
                OnNew(new UserPermission(user, asArray, new[] { permissionKey }), new NewEventArgs());
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:26,代码来源:Permission.cs

示例5: CreateNewMember

        private static Member CreateNewMember(RegisterModel model)
        {
            var user = new User(0);

            var mt = MemberType.GetByAlias(model.MemberTypeAlias) ?? MemberType.MakeNew(user, model.MemberTypeAlias);

            var member = Member.MakeNew(model.Username, mt, user);

            if (model.Name != null)
            {
                member.Text = model.Name;
            }

            member.Email = model.Email;
            member.Password = model.Password;

            if (model.MemberProperties != null)
            {
                foreach (var property in model.MemberProperties.Where(p => p.Value != null))
                {
                    member.getProperty(property.Alias).Value = property.Value;
                }
            }

            member.Save();
            return member;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:27,代码来源:UmbRegisterController.cs

示例6: DoHandleMedia

        public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user)
        {
            // Get umbracoFile property
            var propertyId = media.getProperty("umbracoFile").Id;

            // Get paths
            var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName);
            var ext = Path.GetExtension(destFilePath).Substring(1);

            //var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
            //var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);

            // Set media properties
            media.getProperty("umbracoFile").Value = FileSystem.GetUrl(destFilePath);
            media.getProperty("umbracoBytes").Value = uploadedFile.ContentLength;

            if (media.getProperty("umbracoExtension") != null)
                media.getProperty("umbracoExtension").Value = ext;

            if (media.getProperty("umbracoExtensio") != null)
                media.getProperty("umbracoExtensio").Value = ext;

            FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting);

            // Save media
            media.Save();
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:27,代码来源:UmbracoFileMediaFactory.cs

示例7: DocumentVersionList

 /// <summary>
 /// Initializes a new instance of the DocumentVersionList class.
 /// </summary>
 /// <param name="Version">Unique version id</param>
 /// <param name="Date">Version createdate</param>
 /// <param name="Text">Version name</param>
 /// <param name="User">Creator</param>
 public DocumentVersionList(Guid Version, DateTime Date, string Text, User User)
 {
     _version = Version;
     _date = Date;
     _text = Text;
     _user = User;
 }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:14,代码来源:DocumentVersionList.cs

示例8: ReadFromDisk

        public static void ReadFromDisk(string path)
        {
            if (Directory.Exists(path))
            {
                User user = new User(0); 

                foreach (string file in Directory.GetFiles(path, "*.config"))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(file);

                    XmlNode node = xmlDoc.SelectSingleNode("//Template");

                    if (node != null)
                    {
                       Template.Import(node,user); 
                    }
                }

                foreach (string folder in Directory.GetDirectories(path))
                {
                    ReadFromDisk(folder);
                }
            }
        }
开发者ID:jonnyirwin,项目名称:jumps.umbraco.usync,代码行数:25,代码来源:SyncTemplate.cs

示例9: ReadFromDisk

        public static void ReadFromDisk(string path)
        {
            if (Directory.Exists(path))
            {

                User u = new User(0) ; 

                foreach (string file in Directory.GetFiles(path, "*.config"))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(file);
                                      

                    XmlNode node = xmlDoc.SelectSingleNode("//DataType");

                    if (node != null)
                    {
                        DataTypeDefinition d = Import(node, u);
                        if (d != null)
                        {
                            d.Save();
                        }

                        else
                        {
                            Log.Add(LogTypes.Debug, 0, string.Format("NULL NODE FOR {0}", file));
                        }
                    }
                    
                }
            }
        }
开发者ID:jonnyirwin,项目名称:jumps.umbraco.usync,代码行数:32,代码来源:SyncDataType.cs

示例10: Run

        public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            base.Run(workflowInstance, runtime);

            var body = Helper.Instance.RenderTemplate(RenderTemplate);
            
            IList<string> files = new List<string>();

            foreach(var nodeId in ((UmbracoWorkflowInstance) workflowInstance).CmsNodes)
            {
                var node = new CMSNode(nodeId);
                if(node.IsMedia())
                {
                    files.Add(IOHelper.MapPath((string) new Media(nodeId).getProperty("umbracoFile").Value));
                }
            }

            var f = new User(From).Email;
            foreach(var r in GetRecipients())
            {
                var mail = new MailMessage(f, r) {Subject = Subject, IsBodyHtml = true, Body = body};

                foreach(var file in files)
                {
                    var attach = new Attachment(file);
                    mail.Attachments.Add(attach);
                }

                var smtpClient = new SmtpClient();
                smtpClient.Send(mail);
            }

            runtime.Transition(workflowInstance, this, "done");
        }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:34,代码来源:TemplateEmailWithMediaWorkflowTask.cs

示例11: initialize

        private void initialize(int UserId)
        {
            XmlDocument configFile = config.MetaBlogConfigFile;
            XmlNode channelXml = configFile.SelectSingleNode(string.Format("//channel [user = '{0}']", UserId));
            if (channelXml != null)
            {
                Id = UserId;
                User = new User(UserId);
                Name = channelXml.SelectSingleNode("./name").FirstChild.Value;
                StartNode = int.Parse(channelXml.SelectSingleNode("./startNode").FirstChild.Value);
                FullTree = bool.Parse(channelXml.SelectSingleNode("./fullTree").FirstChild.Value);
                DocumentTypeAlias = channelXml.SelectSingleNode("./documentTypeAlias").FirstChild.Value;
                if (channelXml.SelectSingleNode("./fields/categories").FirstChild != null)
                    FieldCategoriesAlias = channelXml.SelectSingleNode("./fields/categories").FirstChild.Value;
                if (channelXml.SelectSingleNode("./fields/description").FirstChild != null)
                    FieldDescriptionAlias = channelXml.SelectSingleNode("./fields/description").FirstChild.Value;
                if (channelXml.SelectSingleNode("./fields/excerpt") != null && channelXml.SelectSingleNode("./fields/excerpt").FirstChild != null)
                    FieldExcerptAlias = channelXml.SelectSingleNode("./fields/excerpt").FirstChild.Value;

                XmlNode mediaSupport = channelXml.SelectSingleNode("./mediaObjectSupport");
                ImageSupport = bool.Parse(mediaSupport.Attributes.GetNamedItem("enabled").Value);
                MediaFolder = int.Parse(mediaSupport.Attributes.GetNamedItem("folderId").Value);
                MediaTypeAlias = mediaSupport.Attributes.GetNamedItem("mediaTypeAlias").Value;
                MediaTypeFileProperty = mediaSupport.Attributes.GetNamedItem("mediaTypeFileProperty").Value;
            }
            else
                throw new ArgumentException(string.Format("No channel found for user with id: '{0}'", UserId));
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:28,代码来源:config.cs

示例12: DoHandleMedia

        public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user)
        {
            // Get umbracoFile property
            var propertyId = media.getProperty(Constants.Conventions.Media.File).Id;

            // Get paths
            var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName);
            var ext = Path.GetExtension(destFilePath).Substring(1);

            //var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
            //var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);

            // Set media properties
            media.getProperty(Constants.Conventions.Media.File).Value = FileSystem.GetUrl(destFilePath);
            media.getProperty(Constants.Conventions.Media.Bytes).Value = uploadedFile.ContentLength;

            if (media.getProperty(Constants.Conventions.Media.Extension) != null)
                media.getProperty(Constants.Conventions.Media.Extension).Value = ext;

            // Legacy: The 'extensio' typo applied to MySQL (bug in install script, prior to v4.6.x)
            if (media.getProperty("umbracoExtensio") != null)
                media.getProperty("umbracoExtensio").Value = ext;

            FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting);

            // Save media
            media.Save();
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:28,代码来源:UmbracoFileMediaFactory.cs

示例13: Add

        /// <summary>
        /// Adds the specified log item to the log.
        /// </summary>
        /// <param name="type">The log type.</param>
        /// <param name="user">The user adding the item.</param>
        /// <param name="nodeId">The affected node id.</param>
        /// <param name="comment">Comment.</param>
        public static void Add(LogTypes type, User user, int nodeId, string comment)
        {
            if (Instance.ExternalLogger != null)
            {
                Instance.ExternalLogger.Add(type, user, nodeId, comment);

                if (UmbracoConfig.For.UmbracoSettings().Logging.ExternalLoggerEnableAuditTrail == false)
                {
                    AddLocally(type, user, nodeId, comment);
                }
            }
            else
            {
                if (UmbracoConfig.For.UmbracoSettings().Logging.EnableLogging == false) return;

                if (UmbracoConfig.For.UmbracoSettings().Logging.DisabledLogTypes.Any(x => x.LogTypeAlias.InvariantEquals(type.ToString())) == false)
                {
                    if (comment != null && comment.Length > 3999)
                        comment = comment.Substring(0, 3955) + "...";

                    if (UmbracoConfig.For.UmbracoSettings().Logging.EnableAsyncLogging)
                    {
                        ThreadPool.QueueUserWorkItem(
                            delegate { AddSynced(type, user == null ? 0 : user.Id, nodeId, comment); });
                        return;
                    }

                    AddSynced(type, user == null ? 0 : user.Id, nodeId, comment);
                }

            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:39,代码来源:Log.cs

示例14: HandleMedia

        public Media HandleMedia(int parentNodeId, PostedMediaFile postedFile, User user)
        {
            // Check to see if a file exists
            Media media;
            string mediaName = !string.IsNullOrEmpty(postedFile.DisplayName)
                ? postedFile.DisplayName
                : ExtractTitleFromFileName(postedFile.FileName);

            if (postedFile.ReplaceExisting && TryFindExistingMedia(parentNodeId, postedFile.FileName, out media))
            {
                // Do nothing as existing media is returned
            }
            else
            {
                media = Media.MakeNew(mediaName,
                    MediaType.GetByAlias(MediaTypeAlias),
                    user,
                    parentNodeId);
            }

            if (postedFile.ContentLength > 0)
                DoHandleMedia(media, postedFile, user);

            media.XmlGenerate(new XmlDocument());

            return media;
        }
开发者ID:ChrisNikkel,项目名称:Umbraco-CMS,代码行数:27,代码来源:UmbracoMediaFactory.cs

示例15: Add

        /// <summary>
        /// Adds the specified log item to the log.
        /// </summary>
        /// <param name="type">The log type.</param>
        /// <param name="user">The user adding the item.</param>
        /// <param name="nodeId">The affected node id.</param>
        /// <param name="comment">Comment.</param>
        public static void Add(LogTypes type, User user, int nodeId, string comment)
        {
            if (Instance.ExternalLogger != null)
            {
                Instance.ExternalLogger.Add(type, user, nodeId, comment);

                if (!UmbracoSettings.ExternalLoggerLogAuditTrail)
                {
                    AddLocally(type, user, nodeId, comment);
                }
            }
            else
            {
                if (!UmbracoSettings.EnableLogging) return;

                if (UmbracoSettings.DisabledLogTypes != null &&
                    UmbracoSettings.DisabledLogTypes.SelectSingleNode(String.Format("//logTypeAlias [. = '{0}']", type.ToString().ToLower())) == null)
                {
                    if (comment != null && comment.Length > 3999)
                        comment = comment.Substring(0, 3955) + "...";

                    if (UmbracoSettings.EnableAsyncLogging)
                    {
                        ThreadPool.QueueUserWorkItem(
                            delegate { AddSynced(type, user == null ? 0 : user.Id, nodeId, comment); });
                        return;
                    }

                    AddSynced(type, user == null ? 0 : user.Id, nodeId, comment);
                }
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:39,代码来源:Log.cs


注:本文中的umbraco.BusinessLogic.User类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。