Esempio n. 1
0
 public QuestionsController(IInterpreterAsync interpreter, StackUnderflowContext dbContext, DatabaseContext db_Context, IClusterClient clusterClient)
 {
     _interpreter   = interpreter;
     _dbContext     = dbContext;
     _db_Context    = db_Context;
     _clusterClient = clusterClient;
 }
Esempio n. 2
0
 public QuestionController(IInterpreterAsync interpreter, StackUnderflowContext dbContext, IClusterClient client)
 {
     _interpreter = interpreter;
     _dbContext   = dbContext;
     _client      = client;
     Console.WriteLine(_client.GetGrain <IEmailSender>(1));
 }
        /*public async Task OnActivateAsync(StackUnderflowContext dbContext)
         * {
         *  var key = (int)this.GetPrimaryKeyLong();
         *  //Post question = new Post();
         *  var postList = await dbContext.Post.ToListAsync();
         *
         *  var question = from post in postList.Where(r => r.PostId == key)
         *                 //where post.Equals(key.ToString())
         *                  select post.Title;
         *
         * // var expParentPostId = from parentPostId in question.ParentPostId.ToString()
         * //                       where parentPostId.Equals(key.ToString())
         * //                       select parentPostId;
         *
         *
         *  // subscribe to replies stream
         *  IStreamProvider streamProvider = GetStreamProvider("SMSProvider");
         *  IAsyncStream <Post> stream = streamProvider.GetStream<Post>(this.GetPrimaryKey(), "QuestionAndAnswers");
         *  var subscription = await stream.SubscribeAsync((IAsyncObserver<Post>)this);
         *  //return await Task.FromResult(question);
         *  // return base.OnActivateAsync();
         * }*/
        //public override async Task OnActivateAsync()
        //{
        //read state from Db where postid = or parentid=
        //subscribe to reply states
        //var key = (int)this.GetPrimaryKeyLong();
        //IStreamProvider streamProvider = GetStreamProvider("SMSProvider");
        //IAsyncStream<string> stream = streamProvider.GetStream<string>(this.GetPrimaryKey(), "QuestionAndAnswers");
        //var subscription = await stream.SubscribeAsync((IAsyncObserver<string>)this);
        //base.OnActivateAsync();
        //}
        public async Task <IEnumerable <string> > SendQuestionWithAnswers(StackUnderflowContext dbContext)
        {
            var key = (int)this.GetPrimaryKeyLong();

            //IStreamProvider streamProvider = GetStreamProvider("SMSProvider");
            //IAsyncStream<Post> stream = streamProvider.GetStream<Post>(this.GetPrimaryKey(), "QuestionAndAnswers");
            //var subscription = await stream.SubscribeAsync((IAsyncObserver<Post>)this);

            //Post question = new Post();
            var postList = await dbContext.Post.ToListAsync();

            var question = from post in postList.Where(r => r.PostId == key)
                           //where post.Equals(key.ToString())
                           select post.Title.ToString();

            // var parentPostId = from post in question.ParentPostId.ToString()
            //                       where parentPostId.Equals(key.ToString())
            //                       select parentPostId;


            // subscribe to replies stream
            return(await Task.FromResult(question));

            // return base.OnActivateAsync();
        }
Esempio n. 4
0
        public override async Task OnActivateAsync()
        {
            _dbContext = await _interpreter.Interpret(_dbContextPort, Unit.Default);

            _userGrainId = UserGrainId.FromString(this.GetPrimaryKeyString());

            await _dbContext.User.Where(u => u.UserId == _userGrainId.UserId)
            .Include(u => u.TenantUser).ThenInclude(tu => tu.Vote)
            .Include(u => u.TenantUser).ThenInclude(tu => tu.PostTenantUser)
            .LoadAsync();

            _ctx = new UserWriteContext(
                new EFList <User>(_dbContext.User)
                );
        }
Esempio n. 5
0
        public QController(IInterpreterAsync interpreter, StackUnderflowContext dbContext)
        {
            _interpreter = interpreter;
            _dbContext   = dbContext;

            _client = new ClientBuilder()
                      .UseLocalhostClustering()
                      .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "dev";
                options.ServiceId = "OrleansBasics";
            })
                      .AddSimpleMessageStreamProvider("SMSProvider", options => { options.FireAndForgetDelivery = true; })
                      .Build();
        }
Esempio n. 6
0
        public override async Task OnActivateAsync()
        {
            _dbContext = await _interpreter.Interpret(_dbContextFactory, Unit.Default);

            _ctx = await _dbContext.LoadAsync("base.BackofficeGrain", new object(), async reader =>
            {
                var tenants     = await reader.ReadAsync <Tenant>();
                var tenantUsers = await reader.ReadAsync <TenantUser>();
                var users       = await reader.ReadAsync <User>();

                _dbContext.AttachRange(tenants);
                _dbContext.AttachRange(tenantUsers);
                _dbContext.AttachRange(users);
                return(new BackofficeWriteContext(
                           new EFList <Tenant>(_dbContext.Tenant),
                           new EFList <TenantUser>(_dbContext.TenantUser),
                           new EFList <User>(_dbContext.User)));
            });
        }
 public QuestionProjectionGrain(StackUnderflowContext stackUnderflowContext = null)
 {
     _stackUnderflowContext = stackUnderflowContext;
 }
Esempio n. 8
0
 public BackofficeProjectionGrain(StackUnderflowContext dbContext)
 {
     _dbContext = dbContext;
     _dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
Esempio n. 9
0
 public QuestionGrain(StackUnderflowContext dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 10
0
 public EmailSenderGrain(StackUnderflowContext dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 11
0
 public BackofficeController(IInterpreterAsync interpreter, StackUnderflowContext dbContext)
 {
     _interpreter = interpreter;
     _dbContext   = dbContext;
 }
Esempio n. 12
0
 public QuestionProjectionGrain(StackUnderflowContext dbContext)
 {
     _dbContext = dbContext;
     _dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
     _subscriptions = new Collection <StreamSubscriptionHandle <object> >();
 }
 public CreateQuestionController(IInterpreterAsync interpreter, StackUnderflowContext dbContext, IClusterClient client)
 {
     _interpreter = interpreter;
     _dbContext   = dbContext;
     _client      = client;
 }
Esempio n. 14
0
 public QuestionGrain(IInterpreterAsync interpreter, StackUnderflowContext dbContext)
 {
     _interpreter = interpreter;
     //_dbContext = new StackUnderflowContext();
     _dbContext = dbContext;
 }
Esempio n. 15
0
 public BackofficeController(IInterpreterAsync interpreter, StackUnderflowContext dbContext, IClusterClient client)
 {
     _interpreter = interpreter;
     _dbContext   = dbContext;
     _client      = client;
 }
Esempio n. 16
0
 public QuestionController(IInterpreterAsync interpreter, StackUnderflowContext dbContext)
 {
     _interpreter = interpreter;
     _dbContext   = dbContext;
 }
Esempio n. 17
0
 public QuestionGrain(int questionId, StackUnderflowContext dbContext)
 {
     this.questionId = questionId;
     _dbContext      = dbContext;
 }