Пример #1
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();
 }
Пример #2
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();
 }
Пример #3
0
 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;
 }
Пример #4
0
 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;
 }
Пример #5
0
 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;
 }
Пример #6
0
 public void UpdateMessageStatus(string messageId)
 {
     var article = new Article(Schemas.ChatMessage, messageId);
     article.Set("is_seen",true);
     article.SaveAsync();
 }
Пример #7
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;
 }
Пример #8
0
 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);
             }
         }
 }
Пример #9
0
        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;

        }
Пример #10
0
        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;
            }
        }
Пример #11
0
        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;
            }
        }