private static void TestRefreshUserState() { var ds = new DocumentStore { ConnectionStringName = "MasterLive" }; var database = IlluminateDatabase.Create(ds, true, false, false); var orgdb = database.GetOrgStore("leedscc"); var worker = new RefreshUserState(); worker.DoWork(database); }
private bool GenerateDataForATrial(Trial trial) { var orgKey = trial.OrgName.Replace(' ', '_').ToLower() + "_" + Guid.NewGuid(); //set up RavenDB for org store string reservedDatabaseId; var orgStore = _database.ReserveDatabase(trial.RewardPoints, trial.OrgName, orgKey,out reservedDatabaseId); if (orgStore == null) { _logger.Warn(string.Format("No more banked databases left to be used.")); return false; } var splitOwnerName = trial.OwnerName.Split(' '); if (string.IsNullOrEmpty(trial.OwnerName)) { _logger.WarnFormat("Trial name is null or empty"); return false; } if (splitOwnerName.Length < 2) { _logger.WarnFormat("Trial owner name is wrong format {0}",trial.OwnerName); return false; } try { var generator = new TrialDataGenerator(trial.OrgName, splitOwnerName[0], splitOwnerName[1], trial.OwnerEmail, orgKey); var config = generator.GetProvisionerConfig(); _logger.Info( string.Format("About to generate a new trial for orgkey {0}, owner name {1}, owner email {2}", orgKey, trial.OwnerName, trial.OwnerEmail)); var orgDataGenerator = new OrgDataGenerator(config, orgStore, _database.MasterStore, _logger) .GenerateConcern() //.GenerateEmails() .GenerateHigs() .GenerateLeave() .GeneratePraise() .GenerateRewards() .GenerateSickness() //.GenerateYammers() .GenerateTasks() .SetupAvatars(); trial.IsActivated = true; trial.DateActivated = DateTime.UtcNow; var refreshUserState = new RefreshUserState(); refreshUserState.RefreshUserStateFor(orgStore); using (var session = _database.GetMasterSession()) { session.Store(trial); session.SaveChanges(); } _logger.Info(string.Format("processed trial for {0}", orgKey)); return true; } catch (Exception ex) { _logger.ErrorFormat("Problem generating data for a trial - exception {0}",ex); return false; } }