• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BusinessLogic.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: IsCriteriaValid

        public bool IsCriteriaValid(UmbracoWorkflowInstantiationCriteria criteria, User u)
        {
            if(criteria.Users.Count > 0) Log.Debug(string.Format("Validating criteria for users {0}. Current user {1}", string.Join(", ", criteria.Users), u.Id));
            Log.Debug(string.Format("Users contains user {0}", criteria.Users.Contains(u.Id)));

            if(criteria.UserTypes.Count > 0) Log.Debug(string.Format("User type criteria {0} current user {1}", string.Join(", ", criteria.UserTypes), u.UserType.Id));
            Log.Debug(string.Format("UserTypes contains user {0}", criteria.UserTypes.Contains(u.UserType.Id)));

            var userMatches = UserMatches(criteria.Users, u);
            var userTypeMatches = UserTypeMatches(criteria.UserTypes, u);

            
                Log.Debug(string.Format("return: {0} and {1}", userMatches, userTypeMatches));
                if((criteria.Users.Count > 0) && (criteria.UserTypes.Count > 0))
                {
                    if (criteria.CriteriaOperand == "and")
                    {
                        return userMatches && userTypeMatches;
                    }
                    return userMatches || userTypeMatches;
                }

                if(criteria.Users.Count > 0)
                {
                    return userMatches;
                }

                if(criteria.UserTypes.Count > 0)
                {
                    return userTypeMatches;
                }
            return true;
        }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:33,代码来源:UmbracoWorkflowInstantiationCriteriaValidationService.cs


示例17: SendMail

 protected void SendMail(string body)
 {
     var from = new User(From).Email;
     
     foreach (var person in GetRecipients()) 
         SendEmail(from, person, Subject, body, true);
     
 }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:8,代码来源:BaseEmailWorkflowTask.cs


示例18: Save

        public bool Save()
        {

            umbraco.BusinessLogic.User myUser = new umbraco.BusinessLogic.User(0);
            umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Delete, myUser, 0, "Xml save started");
            int id = cms.businesslogic.packager.CreatedPackage.MakeNew(Alias).Data.Id;
            m_returnUrl = string.Format("developer/packages/editPackage.aspx?id={0}", id);
            return true;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:9,代码来源:CreatedPackageTasks.cs


示例19: CopyPermissionsForSingleUser

        /// <summary>
        /// Copies the usertype permissions for single user 
        /// </summary>
        /// <param name="user">The user.</param>
        public static void CopyPermissionsForSingleUser(User user)
        {
            var permissions = GetUserTypePermissions(user.UserType);

                foreach (var permission in permissions)
                {
                    Permission.MakeNew(user, new CMSNode(permission.NodeId), permission.PermissionId);
                    user.initCruds();
                }
        }
开发者ID:rsoeteman,项目名称:usergrouppermissions,代码行数:14,代码来源:UserTypePermissions.cs


示例20: Authorize

        public void Authorize()
        {
            CurrentUser = umbraco.BusinessLogic.User.GetCurrent();

            if (CurrentUser == null)
            {
                HttpContext.Current.Response.StatusCode = 403;
                HttpContext.Current.Response.End();
            }
        }
开发者ID:kgiszewski,项目名称:BabelFish,代码行数:10,代码来源:BabelFishCreateTranslation.aspx.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MacroEngines.DynamicNode类代码示例发布时间:2022-05-26
下一篇:
C# Models.TscData类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap