コード例 #1
0
 public Connection ToNewArticle( string endpointLabel, Article article )
 {
     this.EndpointBLabel = endpointLabel;
     this.EndpointBContent = article;
     this.EndpointBId = null;
     return Build();
 }
コード例 #2
0
 public bool AddUser(Account account, out string errorMessage)
 {
     errorMessage = string.Empty;
     try
     {
         var exUser = Articles.FindAllAsync(Schemas.User, Query.Property("username").IsEqualTo(account.UserName).ToString(), new[] { "__id" }).Result;
         if (exUser == null || exUser.Count == 0)
         {
             User user = new User();
             user.Set("username", account.UserName);
             user.Set("email", account.Email);
             user.Set("firstname", account.FirstName);
             user.Set("lastname", account.LastName);
             user.Set("password", account.Password);
             var profile = new Article(Schemas.Profile);
             profile.Set("total_points", "1");
             profile.Set("level", "1");
             profile.Set("max_game_limit", AppConfigurations.MaxAllowedGamesPerUser);
             var userProfile = Connection.New(Relations.UserProfile)
                 .FromNewArticle(Schemas.User, user)
                 .ToNewArticle(Schemas.Profile, profile).SaveAsync();
             userProfile.Wait();
             account.Id = user.Id;
             return true;
         }
     }
     catch (Exception ex)
     {
         errorMessage = ex.Message;
         return false;
     }
     errorMessage = "User name already exist!!!";
     return false;
 }
コード例 #3
0
 public ConnectionBuilder FromNewArticle(string endpointLabel, Article article )
 {
     this.EndpointALabel = endpointLabel;
     this.EndpointAContent = article;
     this.EndpointAId = null;
     return this;
 }
コード例 #4
0
 public Connection ToExistingArticle( string endpointLabel, string articleId )
 {
     this.EndpointBLabel = endpointLabel;
     this.EndpointBContent = null;
     this.EndpointBId = articleId;
     return Build();
 }
コード例 #5
0
 public void LogMessage(Log log)
 {
     Article article = new Article(Schemas.Log);
     article.Set("name",log.Name);
     article.Set("machine", log.MachineName);
     article.Set("sessionid", log.SessionId);
     article.Set("request", log.Request);
     article.Set("response", log.Response);
     article.Set("servicename", log.ServiceName);
     article.Set("status", log.Status);
     article.Set("timetaken", log.TimeTaken);
     article.SaveAsync();
 }
コード例 #6
0
ファイル: MovesDataProvider.cs プロジェクト: TokleMahesh/GOB
 public List<Move> GetNextMoves(string gameId, List<string> existingIds)
 {
     Article game = new Article(Schemas.Game, gameId);
     var moveArticleIds = game.GetAllConnectedArticles(Relations.GameMove, null, null,new[] {"__id"});
     var moveIds = moveArticleIds.Select(m => m.Id).ToList();
     moveIds = moveIds.Except(existingIds).ToList();
     List<Move> moves = new List<Move>();
     if (moveIds.Count > 0)
     {
         var graphMoves = Graph.Project("get_next_moves", moveIds, null).Result;
         moves = graphMoves.Select(node => node.Article).ToList().ToModelMoves();
     }
     return moves;
 }
コード例 #7
0
ファイル: GameDataProvider.cs プロジェクト: TokleMahesh/GOB
 public Game CreateGame(string userId, GameStatus status, bool isActive, List<string> tiles, List<string> gameTiles)
 {
     var user = new User(userId);
     var game = new Article(Schemas.Game);
     game.Set("status", status.ToString());
     game.Set("tiles", string.Join(",", gameTiles));
     var conn = Connection.New(Relations.GamePlayer)
         .FromExistingArticle("player", userId)
         .ToNewArticle("game", game);
     conn.Set("ishost", true);
     conn.Set("isactive", isActive);
     conn.Set("tiles", string.Join("|", tiles));
     conn.Set("tiles_remaining", AppConfigurations.MaxTilesPerPlayer);
     conn.SaveAsync().Wait();
     return game.ToModelGame();
 }
コード例 #8
0
 public void LogException(Exception exception, string source, string method, Severity severity)
 {
     var log = new ExceptionLog(exception, source, method, severity);
     Article article = new Article(Schemas.Exception);
     article.Set("title",log.Title);
     article.Set("type", log.Type);
     article.Set("severity", log.Severity);
     article.Set("message", log.Message);
     article.Set("sessionid", log.SessionId);
     article.Set("machine", log.MachineName);
     article.Set("appdomain", log.AppDomainName);
     article.Set("source", log.Source);
     article.Set("targetsite", log.TargetSite);
     article.Set("statcktrace", log.StackTrace);
     article.Set("additioninfo", log.AdditionalInfo);
     article.Set("innerexception", log.InnerException);
     article.SaveAsync();
 }
コード例 #9
0
ファイル: ArticleExtensions.cs プロジェクト: TokleMahesh/GOB
 public static Account ToModelAccount(this User user, Article profile)
 {
     if (user == null)
         return null;
     Account account = new Account()
     {
         UserName = user.Get<string>("username"),
         Email = user.Get<string>("email"),
         FirstName = user.Get<string>("firstname"),
         LastName = user.Get<string>("lastname"),
         Id = user.Id
     };
     if (profile != null)
     {
         account.MaxGameLimit = profile.Get<int>("max_game_limit",0);
         account.Level = profile.Get<int>("level",0);
         account.Points = profile.Get<int>("total_points", 0);
     }
     return account;
 }
コード例 #10
0
 public string SaveMessage(ChatMessage message)
 {
     var article = new Article(Schemas.ChatMessage);
     article.Set("from", message.From);
     article.Set("to", message.To);
     article.Set("message", message.Message);
     article.SaveAsync().Wait();
     return article.Id;
 }
コード例 #11
0
ファイル: GameDataProvider.cs プロジェクト: TokleMahesh/GOB
 public bool StartGame(string gameId, string userId, GameStatus status, bool isActive, List<string> tiles, List<string> gameTiles)
 {
     var game = new Article(Schemas.Game, gameId);
     var players = game.GetAllConnectedArticles(Relations.GamePlayer, null, null, new[] {"__id"});
     if (players != null && players.Count == 1)
     {
         game.Set("status", status.ToString());
         game.Set("tiles", string.Join(",", gameTiles));
         var conn = Connection.New(Relations.GamePlayer)
             .FromExistingArticle("player", userId)
             .ToExistingArticle("game", gameId);
         conn.Set("ishost", false);
         conn.Set("isactive", isActive);
         conn.Set("tiles", string.Join("|", tiles));
         conn.Set("tiles_remaining", AppConfigurations.MaxTilesPerPlayer);
         conn.SaveAsync().Wait();
         game.SaveAsync().Wait();
         return true;
     }
     return false;
 }
コード例 #12
0
ファイル: GameDataProvider.cs プロジェクト: TokleMahesh/GOB
 public bool SaveGameTiles(string gameId, List<string> gameTiles)
 {
     var gameArticle = new Article(Schemas.Game, gameId);
     gameArticle.Set("tiles", string.Join(",",gameTiles));
     gameArticle.SaveAsync();
     return true;
 }
コード例 #13
0
ファイル: GameDataProvider.cs プロジェクト: TokleMahesh/GOB
 public bool SaveGameStatus(string gameId, GameStatus status)
 {
     var article = Articles.GetAsync(Schemas.Game, gameId, new[] {"status"}).Result;
     if (!string.Equals(GameStatus.Finished.ToString(), article.Get<string>("status"), StringComparison.OrdinalIgnoreCase))
     {
         var game = new Article(Schemas.Game, gameId);
         game.Set("status", status.ToString());
         game.SaveAsync().Wait();
     }
     return true;
 }
コード例 #14
0
 public User(Article device)
     : base(device)
 {   
 }
コード例 #15
0
ファイル: Program.cs プロジェクト: neilunadkat/usage
        private async Task<string> CreateAppArticle(AppInfo appInfo)
        {
            dynamic obj = new Article("appdayusage");
            Convert(obj,appInfo);
            await obj.SaveAsync();
            var created = obj as Article;
            return created.Id;

        }
コード例 #16
0
ファイル: Program.cs プロジェクト: neilunadkat/usage
 private async Task CreateAppMonthlyUsage(string month, AppInfo appInfo)
 {
         if (this._appMonthlyArticleIds.ContainsKey(GetAppMonthId(appInfo.ApplicationId, month)) == false)
         {
             this._appMonthlyArticleIds[GetAppMonthId(appInfo.ApplicationId, month)] = "0";
             var query = BooleanOperator.And(new[]
             {
                 Query.Property("application_id").IsEqualTo(appInfo.ApplicationId),
                 Query.Property("month").IsEqualTo(month)
             })
                                          .AsString()
                   ;
             var appMonthly = await Articles.FindAllAsync("appmonthlyusage", query);
             if (appMonthly.Count == 0)
             {
                 dynamic obj = new Article("appmonthlyusage");
                 obj.application_id = appInfo.ApplicationId;
                 obj.application_name = appInfo.ApplicationName;
                 obj.account_name = appInfo.AccountName;
                 obj.email = appInfo.Email;
                 obj.application_name = appInfo.ApplicationName;
                 obj.month = month;
                 obj.sandbox_deploymentid = appInfo.Sandbox_DeploymentId;
                 obj.live_deploymentid = appInfo.Live_DeploymentId;
                 obj.account_id = appInfo.AccountId;
                 await obj.SaveAsync();
                 var created = obj as Article;
                 if (string.IsNullOrEmpty(created.Id) == false)
                 {
                     this._appMonthlyArticleIds[GetAppMonthId(appInfo.ApplicationId, month)] = created.Id;
                 }
             }
             else 
             {
                 this._appMonthlyArticleIds[GetAppMonthId(appInfo.ApplicationId, month)] = appMonthly[0].Id;
             }
         }
         else if (this._appMonthlyArticleIds[GetAppMonthId(appInfo.ApplicationId, month)] == "0") 
         {
             while (this._appMonthlyArticleIds[GetAppMonthId(appInfo.ApplicationId, month)] == "0") 
             {
                 Thread.Sleep(50);
             }
         }
 }
コード例 #17
0
        public Connection(string type, string labelA, Article articleA, string labelB, Article articleB)
            : base(type)
        {
            Endpoint ep1, ep2;
            string nullId = null;
            if (articleA.IsNewInstance == true)
            {
                ep1 = new Endpoint(labelA, nullId);
                ep1.Content = articleA;
            }
            else
                ep1 = new Endpoint(labelA, articleA.Id);

            if (articleB.IsNewInstance == true)
            {   
                ep2 = new Endpoint(labelB, nullId);
                ep2.Content = articleB;
            }
            else
                ep2 = new Endpoint(labelB, articleB.Id);

            this.Endpoints = new EndpointPair(ep1, ep2);
        }
コード例 #18
0
ファイル: MovesDataProvider.cs プロジェクト: TokleMahesh/GOB
 public Move SaveMove(string gameId, Move move)
 {
     Article moveArticle = new Article(Schemas.Moves);
     moveArticle.Set("move_code", move.MoveCode);
     moveArticle.Set("points", move.Points);
     moveArticle.Set("player", move.Player);
     var con = Connection.New(Relations.GameMove)
         .FromExistingArticle(Schemas.Game, gameId)
         .ToNewArticle(Schemas.Moves, moveArticle);
     con.SaveAsync().Wait();
     move = moveArticle.ToModelMove();
     move.TimeStamp = DateTime.UtcNow;
     return move;
 }
コード例 #19
0
 protected Article(Article existing) : base(existing)
 {
     // Copy
     this.SchemaId = existing.SchemaId;
 }
コード例 #20
0
 public Device(Article device)
     : base(device)
 {
     this.Channels = new MultiValueCollection<string>(this, "channels");
 }
コード例 #21
0
 public Endpoint(string label, Article content)
 {
     this.Label = label;
     this.Content = content;
 }
コード例 #22
0
ファイル: Program.cs プロジェクト: neilunadkat/usage
        private  async Task SetDailyUsage(DateTime day)
        {
            var articles = await Articles.FindAllAsync("dailyusage", Query.Property("day").IsEqualToDate(day).AsString());
            string id = "";
            if (articles.Count == 0)
            {
                dynamic article = new Article("dailyusage");
                article.day = DataSource.DayFormat(day);
                await article.SaveAsync();
                var created = article as Article;
                if (created != null)
                {
                    _dailyArticleIds[day] = created.Id;
                }


            }
            else
            {
                _dailyArticleIds[day] = articles[0].Id;
            }
        }
コード例 #23
0
 public void UpdateMessageStatus(string messageId)
 {
     var article = new Article(Schemas.ChatMessage, messageId);
     article.Set("is_seen",true);
     article.SaveAsync();
 }
コード例 #24
0
ファイル: Program.cs プロジェクト: neilunadkat/usage
        private  async Task SetMonthlyUsage(string month)
        {
            var articles = await Articles.FindAllAsync("monthlyusage", Query.Property("month").IsEqualTo(month).AsString());
            string id = "";
            if (articles.Count == 0)
            {
                dynamic article = new Article("monthlyusage");
                article.month = month;
                await article.SaveAsync();
                var created = article as Article;
                if (created != null)
                {
                    _monthArticleIds[month] = created.Id;
                }


            }
            else
            {
                _monthArticleIds[month] = articles[0].Id;
            }
        }
コード例 #25
0
 public Connection(string type, string labelA, Article articleA, string labelB, string ArticleIdB)
     : base(type)
 {
     Endpoint ep1, ep2;
     if (articleA.IsNewInstance == false)
     {
         ep1 = new Endpoint(labelA, articleA.Id);
         ep2 = new Endpoint(labelB, ArticleIdB);
     }
     else
     {
         string nullId = null;
         ep1 = new Endpoint(labelA, nullId);
         ep2 = new Endpoint(labelB, ArticleIdB);
         ep1.Content = articleA;
     }
     this.Endpoints = new EndpointPair(ep1, ep2);
 }
コード例 #26
0
 public Connection(string type, string labelA, Article articleA, string labelB, string ArticleIdB)
     : base(type)
 {
     if (articleA.IsNewInstance == false)
     {
         this.EndpointA = new Endpoint(labelA, articleA.Id);
         this.EndpointB = new Endpoint(labelA, ArticleIdB);
     }
     else
     {
         this.EndpointA = new Endpoint(labelA, null);
         this.EndpointB = new Endpoint(labelA, ArticleIdB);
         this.EndpointA.Content = articleA;
     }
 }