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


C# IDocumentSession类代码示例

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


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

示例1: AddUser

        public void AddUser(User user, IDocumentSession session)
        {
            if (user == null) throw new ArgumentNullException("user");
            if (session == null) throw new ArgumentNullException("session");

            try
            {
                session.Advanced.UseOptimisticConcurrency = true;

                session.Store(user);

                var facebookId = new FacebookId
                                     {
                                         Id = FacebookId.MakeKey(user.FacebookId),
                                         UserId = user.Id
                                     };

                session.Store(facebookId);
                session.SaveChanges();
            }
            finally
            {
                session.Advanced.UseOptimisticConcurrency = false;
            }
        }
开发者ID:rdingwall,项目名称:100books,代码行数:25,代码来源:UserRepository.cs

示例2: PCNarration

        public static PostHandlerOutput[] PCNarration(
            IDocumentSession documentSession,
            IMember sender,
            IRoom room,
            string source)
        {
            documentSession.Ensure("documentSession");
            sender.Ensure("sender");
            room.Ensure("room");
            source.Ensure("source");

            source = source.Trim();
            if (source.StartsWith("/", StringComparison.OrdinalIgnoreCase))
                return null;

            if (!sender.IsRoomPlayer(room))
                return null;

            var player = room.Players.SingleOrDefault(x => x.MemberId == sender.Id);
            if (player == null)
                return null;

            var text = string.Concat(
                player.CharacterName,
                ": ",
                source);

            documentSession.CreatePost(room.Id, sender.Id, null, source, "pc-narration", text);

            return PostHandlerOutput.Empty;
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:31,代码来源:PCNarration.cs

示例3: ScanRobotsModule

        public ScanRobotsModule(IDocumentSession documentSession)
        {
            Get["/scanRobots/"] = parameters =>
            {
                var inputModel = this.Bind<CreateScanRobotsInputModule>();

                var robotsScanResult =
                    documentSession.Advanced.LuceneQuery<RobotPosition>("RobotPositions/ByNameAndLocation")
                        .WhereEquals("Online", true)
                        .WhereGreaterThan("LastUpdate", DateTime.Now.AddMinutes(-1))
                        .WithinRadiusOf(radius: 10, latitude: inputModel.Latitude, longitude: inputModel.Longitude)
                        .ToList();

                return Response.AsJson(robotsScanResult.Where(r => r.RobotName != inputModel.RobotName).ToArray());
            };

            Get["/scanAllRobots/"] = parameters =>
            {
                var robotsScanResult =
                    documentSession.Query<RobotPosition>().Customize(x => x.WaitForNonStaleResultsAsOfNow()).Where(
                        r => r.Online && r.LastUpdate > DateTime.Now.AddMinutes(-1)).ToList();

                var response = Response.AsJson(robotsScanResult.ToArray());
                response.Headers.Add("Access-Control-Allow-Origin", "*");
                return response;
            };
        }
开发者ID:emilcardell,项目名称:ForeverRobot,代码行数:27,代码来源:ScanRobotsModule.cs

示例4: WelcomeModule

        public WelcomeModule(IDocumentSession session)
            : base("Welcome")
        {
            Get["/"] = p => View["Welcome"];

            Post["/"] = p =>
            {
                var user = this.Bind<User>("Password", "Salt", "Claims");
                user.Claims = new List<string> {"admin"};
                NSembleUserAuthentication.SetUserPassword(user, Request.Form.Password);
                session.Store(user, "users/" + user.Email);

                session.Store(new Dictionary<string, AreaConfigs>
                                      {
                                          //{"/blog", new AreaConfigs { AreaName = "MyBlog", ModuleName = "Blog" }},
                                          //{"/content", new AreaConfigs { AreaName = "MyContent", ModuleName = "ContentPages" }},
                                          {"/auth", new AreaConfigs { AreaName = "Auth", ModuleName = "Membership" }}
                                      }, Constants.AreasDocumentName);

                session.SaveChanges();

                // Refresh the Areas configs
                AreasResolver.Instance.LoadFromStore(session);

                return Response.AsRedirect("/");
            };
        }
开发者ID:synhershko,项目名称:NSemble,代码行数:27,代码来源:WelcomeModule.cs

示例5: EntryToEntryViewModelMapper

 public EntryToEntryViewModelMapper(
     IDocumentSession session,
     UrlHelper urlHelper)
 {
     this.session = session;
     this.urlHelper = urlHelper;
 }
开发者ID:bbqchickenrobot,项目名称:byteblog,代码行数:7,代码来源:EntryToEntryViewModelMapper.cs

示例6: ValidateUser

        public static string ValidateUser(IDocumentSession ravenSession, string username, string password)
        {
            // try to get a user from the database that matches the given username and password
            var userRecord = ravenSession.Load<User>("users/" + username);
            if (userRecord == null)
            {
                return null;
            }

            // verify password
            var hashedPassword = GenerateSaltedHash(password, userRecord.Salt);
            if (!CompareByteArrays(hashedPassword, userRecord.Password))
                return null;

            // cleanup expired or unusesd tokens
            foreach (var token in ravenSession.Query<ApiKeyToken>().Where(x => x.UserId == userRecord.Id))
            {
                if (DateTimeOffset.UtcNow.Subtract(TimeSpan.FromDays(7)) > token.LastActivity)
                    ravenSession.Delete(token);
            }

            // now that the user is validated, create an api key that can be used for subsequent requests
            var apiKey = Guid.NewGuid().ToString();
            ravenSession.Store(new ApiKeyToken { UserId = userRecord.Id, SessionStarted = DateTimeOffset.UtcNow, LastActivity = DateTimeOffset.UtcNow }, GetApiKeyDocumentId(apiKey));
            ravenSession.SaveChanges();

            return apiKey;
        }
开发者ID:synhershko,项目名称:NSemble,代码行数:28,代码来源:NSembleUserAuthentication.cs

示例7: DeleteMember

        static object DeleteMember(
            NancyContext context,
            IDocumentSession documentSession,
            string alias)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (documentSession == null) throw new ArgumentNullException("documentSession");

            if (String.IsNullOrEmpty(alias))
                return 404;

            if (!context.IsSignedUp())
                return 403;

            var memberToDelete = documentSession.GetMemberByAlias(alias);
            if (memberToDelete == null)
                return 404;

            var currentMember = context.GetCurrentMember(documentSession);
            Debug.Assert(currentMember != null, "`requireSignedUp()` should ensure the current member is not null.");

            if (!memberToDelete.Alias.Equals(currentMember.Alias, StringComparison.OrdinalIgnoreCase))
                return 403;

            documentSession.DeleteMember(memberToDelete.Id);

            context.SetAlert("Your membership was deleted.", type: AlertType.Success);

            context.SignOutOfTwitter();

            return context.Redirect(Paths.Home());
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:32,代码来源:MemberModule.cs

示例8: CommandsToPickUpBehaviour

 public CommandsToPickUpBehaviour(IFubuRequest request,IOutputWriter writer,IDocumentSession session)
     : base(PartialBehavior.Ignored)
 {
     this.request = request;
     this.writer = writer;
     this.session = session;
 }
开发者ID:northshoreab,项目名称:Hygia,代码行数:7,代码来源:CommandsToPickUpBehaviour.cs

示例9: StubDocumentStoreWithSession

        public static IDocumentStore StubDocumentStoreWithSession(IDocumentSession session)
        {
            var store = MockRepository.GenerateStub<IDocumentStore>();

            store.Stub(x => x.OpenSession()).Return(session);
            return store;
        }
开发者ID:mamluka,项目名称:SpeedyMailer,代码行数:7,代码来源:DocumentStoreFactory.cs

示例10: RecordPhonecall

 public RecordPhonecall(IPayAsYouGoAccountRepository payAsYouGoAccountRepository,
                    IDocumentSession unitOfWork, IClock clock)
 {
     _payAsYouGoAccountRepository = payAsYouGoAccountRepository;
     _unitOfWork = unitOfWork;
     _clock = clock;
 }
开发者ID:elbandit,项目名称:PPPDDD,代码行数:7,代码来源:RecordPhonecall.cs

示例11: RavenFileRepository

		public RavenFileRepository(IDocumentSession documentSession, IFileStorage fileStorage, IUserIdentity userIdentity, ILog logger)
		{
			_documentSession = DIHelper.VerifyParameter(documentSession);
			_fileStorage = DIHelper.VerifyParameter(fileStorage);
			_userIdentity = DIHelper.VerifyParameter(userIdentity);
			_logger = DIHelper.VerifyParameter(logger);
		}
开发者ID:gsbastian,项目名称:Sriracha.Deploy,代码行数:7,代码来源:RavenFileRepository.cs

示例12: GMNarration

        public static PostHandlerOutput[] GMNarration(
            IDocumentSession documentSession,
            IMember sender,
            IRoom room,
            string source)
        {
            documentSession.Ensure("documentSession");
            sender.Ensure("sender");
            room.Ensure("room");
            source.Ensure("source");

            if (!sender.IsRoomOwner(room))
                return null;

            source = source.Trim();

            if (source.StartsWith("/", StringComparison.OrdinalIgnoreCase))
                return null;

            var text = string.Concat(
                "GM: ",
                source);

            documentSession.CreatePost(room.Id, sender.Id, null, source, "gm-narration", text);

            return PostHandlerOutput.Empty;
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:27,代码来源:GMNarration.cs

示例13: GetUser

        public User GetUser(string userId, IDocumentSession session)
        {
            if (userId == null) throw new ArgumentNullException("userId");
            if (session == null) throw new ArgumentNullException("session");

            return session.Load<User>(userId);
        }
开发者ID:rdingwall,项目名称:100books,代码行数:7,代码来源:UserRepository.cs

示例14: Run

 public bool? Run(IDocumentSession openSession)
 {
     Initialize(openSession);
     try
     {
         Execute();
         DocumentSession.SaveChanges();
         TaskExecutor.StartExecuting();
         return true;
     }
     catch (ConcurrencyException e)
     {
         OnError(e);
         return null;
     }
     catch (Exception e)
     {
         OnError(e);
         return false;
     }
     finally
     {
         TaskExecutor.Discard();
     }
 }
开发者ID:jamesfarrer,项目名称:docs,代码行数:25,代码来源:BackgroundTask.cs

示例15: DoCommit

 private void DoCommit(IDocumentSession session)
 {
    foreach (IAggregateRoot root in _trackedObjects)
    {
       Store(session, root);
    }
 }
开发者ID:ssajous,项目名称:DDDSample.Net,代码行数:7,代码来源:UnitOfWork.cs


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