Ejemplo n.º 1
0
        public override void DoWork(IlluminateDatabase database)
        {
            var status = "success"; 
            logger.Information("RefreshUserState started");
            
            foreach (var orgdb in database.GetAllOrgStores())
            {

                logger.Information("RefreshUserState on {0}", orgdb);
                try
                {
                    RefreshUserStateFor(orgdb);
                }
                catch (Exception ex)
                {
                    logger.Exception(ex);
                    status = "errors"; 
                }
                
                
            }


            logger.Information("RefreshUserState completed with {0}", status);
        }
Ejemplo n.º 2
0
        public override void DoWork(IlluminateDatabase database)
        {
            int totalUsers,connectedUsers;
            using (var masterSession = database.MasterStore.OpenSession())
            {
                RavenQueryStatistics authUserStats;
                masterSession.Query<AuthUser>()
                                           .Statistics(out authUserStats)
                                           .ToArray();
                totalUsers = authUserStats.TotalResults;

                RavenQueryStatistics connectedUserStats;
                masterSession.Query<ConnectedUser>()
                                           .Statistics(out connectedUserStats)
                                           .ToArray();
                connectedUsers = connectedUserStats.TotalResults;
            }
            

            var apiKey = ConfigurationManager.AppSettings.Get("HOSTEDGRAPHITE_APIKEY");
            try
            {
                using (var client = new GraphiteUdpClient(HostedGraphiteUrl, HostedGraphitePort, apiKey))
                {

                    client.Send(_totalUsersMetric, totalUsers);
                    client.Send(_connctedUsersMetric, connectedUsers);
                }
            }
            catch 
            {
                
            }
        }
Ejemplo n.º 3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DataBase = IlluminateDatabase.Create(new DocumentStore { ConnectionStringName = "RavenServer" });
        }
Ejemplo n.º 4
0
        protected void Application_Start()
        {
            //hook into the fed auth config created event do we can do some extra steps
            //FederatedAuthentication.FederationConfigurationCreated += FederatedAuthentication_FederationConfigurationCreated;
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DataBase = IlluminateDatabase.Create(new DocumentStore { ConnectionStringName = "RavenServer" }, true,false,false);

            Mappings.Initialise();

            
            
        }
Ejemplo n.º 5
0
        protected override void OnApplicationStarted()
        {
            //hook into the fed auth config created event do we can do some extra steps
            FederatedAuthentication.FederationConfigurationCreated += FederatedAuthentication_FederationConfigurationCreated;
            XmlConfigurator.Configure(); //configure logging
            Logger = LogManager.GetLogger("Illuminate");
            Logger.Information("Illuminate Web Application Started");

            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteTable.Routes.MapHubs();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Logger.Information("About to create master store when starting Illuminate");
            DataBase = IlluminateDatabase.Create(new DocumentStore { ConnectionStringName = "RavenServer" });
            Logger.Information("Created master store when starting Illuminate");
            Mappings.Initialise();
            BinderConfig.RegisterBinders();

            var accountRepoStore = new DocumentStore {ConnectionStringName = "RavenServer"};
            accountRepoStore.Initialize();
            var accountRepo = new RavenUserAccountRepository(accountRepoStore);
            UserAccountService = new UserAccountService(accountRepo)
            {
                Configuration = MembershipRebootConfig.Create()
            };
            RebootAuthenticationService = new SamAuthenticationService(UserAccountService);
            //in DEBUG mode attach raven profiler so we can profile all org stores if needed
#if DEBUG
            foreach (var store in DataBase.GetAllOrgStores().Where(store => store.Identifier.EndsWith("halethorpe")))
            {
                Raven.Client.MvcIntegration.RavenProfiler.InitializeFor(store);
            }
            //Raven.Client.MvcIntegration.RavenProfiler.InitializeFor(DataBase.MasterStore);
#endif
            //task manager does some stuff as background processes
            Logger.Information("about to initialize taskmanager when starting Illuminate");
            TaskManager.Initialize(new IlluminateRegistry());
            Logger.Information("Initialized taskmanager when starting Illuminate");
            
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Please implement. This should do the work, then update the task with the work done. 
 /// </summary>
 /// <param name="database"></param>
 public abstract void DoWork(IlluminateDatabase database);
Ejemplo n.º 7
0
        private void Initialise()
        {
            //var connectionString = @"Url=https://ec2-eu3.cloudbird.net/databases/7a5d73c5-0ac0-4a4a-8ea7-5a6d9402bcf2.Illuminate;ApiKey=9805e60a-1624-4261-9204-376eabae4a1b";
            //#if DEBUG
            // connectionString = @"Url=http://localhost:8080/Databases/master";
            //#endif
            var ds = IlluminateDatabase.GetMasterFromConfig();

            _database = IlluminateDatabase.Create(ds);

            _logger.Information("Schedule worker initialised");
        }
Ejemplo n.º 8
0
        public void DoWork(IlluminateDatabase database,IEmailSender emailSender)
        {
            Logger.Information("EmailDailyTasks started");
            
            

            //we need to get a list of tasks that are Overdue, duetoday or due tomorrow. 
            foreach (var db in database.GetAllOrgStores())
            {
                Currentstore = db; 

                List<User> users;
                using (var session = db.OpenSession())
                {
                    users = session.Query<User>().ToList();
                }

                //get the tasks etc for this user. 
                foreach (var user in users)
                {
                    Currentuser = user; 


                    //set culture
                    Thread.CurrentThread.CurrentCulture = user.Culture;


                    var bodyBuilder = new StringBuilder(); 

                    using (var session = db.OpenSession()) //smaller sessions
                    {
                        var targetuser = user;

                        var tasks =
                            session.Query<Task>()
                                    .Where(
                                        x =>
                                        x.ConsolidatedAssignees.Any(a => a.UserId == targetuser.Id) &&
                                        x.DueDate <= DateTime.Today.AddDays(3) && x.CompletedDate == null);
                            
                        var meetings =
                            session.Query<Meeting>()
                                    .Where(
                                        x =>
                                        x.Invitees.Any(i => i.UserId == targetuser.Id) &&
                                        x.DueDate <= DateTime.Today.AddDays(3) &&
                                        x.DueDate >= DateTime.Today); 

                        var items = new List<TimelineItem>();

                        items.AddRange(tasks.ToList().ToTimelineItems());
                        items.AddRange(meetings.ToList().ToTimelineItems());

                        Logger.Information("{0} items for {1}", items.Count, targetuser.Name);

                        var sectionbuilder = new StringBuilder();

                       
                        if (items.Count > 0)
                        {
                         

                            var overduelines =
                                (from i in items
                                    where i.start.Date < DateTime.Today
                                    orderby i.start ascending
                                 select FormatItem(i));
                            sectionbuilder.AppendLine(SubHeader("Overdue tasks"));
                            
                            if (overduelines.Any())
                            {
                                sectionbuilder.Append(String.Join("\n", overduelines.ToList()));
                            }
                            else
                            {
                                sectionbuilder.AppendLine("No items to show<br/>"); 
                            }

                            sectionbuilder.AppendLine("<br/>"); 

                            var todaylines =
                                (from i in items
                                 where i.start.Date == DateTime.Today
                                 orderby i.start ascending
                                 select FormatItem(i));


                            sectionbuilder.AppendLine(SubHeader("Today's tasks"));
                            
                            if (todaylines.Any())
                            {
                                sectionbuilder.Append(String.Join("\n", todaylines.ToList()));
                            }
                            else
                            {
                                sectionbuilder.AppendLine("No items to show<br/>");
                            }

                            sectionbuilder.AppendLine("<br/>");

                            var futurelines =
                                (from i in items
                                 where i.start.Date > DateTime.Today
                                 orderby i.start ascending
                                 select FormatItem(i));


                            sectionbuilder.AppendLine(SubHeader("Upcoming tasks"));
                            
                            if (futurelines.Any())
                            {
                                sectionbuilder.Append(String.Join("\n", futurelines.ToList()));
                            }
                            else
                            {
                                sectionbuilder.AppendLine("No items to show<br/>");
                            }



                        }
                        




                        //TODO: Add Insights



                        //TODO: Add Messages


                        //render section
                        bodyBuilder.Append(Email.WrapSection(sectionbuilder.ToString()));

                        //clear section builder. 
                        sectionbuilder.Clear();


                        //TODO: Add KPIs



                        if (targetuser.CanManageOthers) //TODO: no point if they don't have any managees. 
                        {
                            //TODO: Add Team KPIs


                            //TODO: Add Team HIG

                        }


                        var stuffToSend = (targetuser.EmailAddress == "*****@*****.**"); 


                        //Done
                        if (stuffToSend)//only send if stuff to send?
                        {
                            var email = new Email();
                            email.To.Add(new EmailRecipient
                                             {
                                                 Name = targetuser.Name,
                                                 Email = targetuser.EmailAddress
                                             });


                            const string headertemplate = "<table style='text-align:left;width:100%;padding:0px; margin-top:0px;' cellpadding='0' cellspacing='0'><tr><td style='width:0px;'>{0}&nbsp;</td><td style='font-family: Helvetica,Arial,sans-serif; line-height: 1.3; text-decoration: none; font-size: 18px; font-weight: bold; color: #FFF; padding: 0'>{1}</td></tr></table>"; 

                            var headername = new StringBuilder();
                            headername.AppendLine(targetuser.Name + "<br/>");
                            headername.AppendLine(String.Format("<div style='font-size:14px;'>{0}</div>", DateTime.Today.ToShortDateString()));

                            var headeravatar = String.Format(AvatarImageString,
                                                             ImageHelper.GetAvatarUrl(user.Avatar.PublicID, 50),
                                                             user.Name); 

                            email.Subject = "Your Illuminate Daily Update";
                            email.Body = Email.WrapBody(HostName, "Illuminate Daily Update", String.Format(headertemplate, headeravatar, headername), bodyBuilder.ToString());

                            emailSender.Send(email);
                            
                        }
                    }

                }
            }
            
        }
Ejemplo n.º 9
0
 public TrialProcessor(IlluminateDatabase database,ILog logger)
 {
     _database = database;
     _logger = logger;
 }