public void Invoke(IUser user,IInferenceType inferenceType,IDocumentSession session)
        {
            //create a new notification and save it
            var notification = new Notification
                                   {
                                       About = user.ToSimpleUser(),
                                       Id = IlluminateDatabase.GenerateId<Notification>(),
                                       SendDate = DateTime.Now,
                                       From = EmailRecipient.GetIlluminateRecipient(),
                                       Title = "Illuminate Inference",
                                       Body = inferenceType.GetDescription(user),
                                       NotificationRecipients = new NotificationRecipient[]
                                                                    {
                                                                        new NotificationRecipient
                                                                            {

                                                                                NotificationDeliveryTypes =
                                                                                    NotificationDeliveryTypes
                                                                                        .Toast |
                                                                                    NotificationDeliveryTypes
                                                                                        .Email,
                                                                                Users = user.Relationships
                                                                                            .Where(
                                                                                                r =>
                                                                                                r.RelationshipName ==
                                                                                                Role.BuiltInRole
                                                                                                    .LineManager
                                                                                                    .ToString())

                                                                            }
                                                                    }
                                   };

           session.Store(notification);
           session.SaveChanges();
            
        }
示例#2
0
 private void AddNotifications(IUser user, IUser manager)
 {
     var notifications = _pocoSession.List<Notification>(_numNotificationsPerUser).Get();
     foreach (var notification in notifications)
     {
         notification.Id = Guid.NewGuid();
         notification.NotificationRecipients = new []
                                                   {
                                                       new NotificationRecipient
                                                           {
                                                               NotificationDeliveryTypes =
                                                                   NotificationDeliveryTypes
                                                                       .Email |
                                                                   NotificationDeliveryTypes
                                                                       .Toast,
                                                               Users =
                                                                   new[]
                                                                       {
                                                                           user.ToSimpleUser()
                                                                       }
                                                           }
                                                   };
         Notifications.Add(notification);
     }
 }
示例#3
0
        private void AddLeaves(IUser user, IUser manager)
        {
            for (var count = 1; count <= _numLeavesPerUser; count++)
            {
                Leaves.Add(new Leave
                {
                    CurrentProcessOwner = manager.ToSimpleUser(),
                    Id = Guid.NewGuid(),
                    LeaveType = _leaveType,
                    Title = string.Format("test leave for {0}", user.Name),
                    Summary = string.Format("test leave summary for {0} ssa dsasa as dasasdsd dsdsdsd dsd", user.Name),
                    StartOfProcess = DateTime.Now.AddDays(0 - (_rand.Next(365 * _numYearsToGoBack))),
                    Subject = user.ToSimpleUser(),
                    ConsolidatedCompletionDate = DateTime.Now.AddDays(0 - (_rand.Next(365 * _numYearsToGoBack))),

                });
            }

        }
示例#4
0
 private void AddPraises(IUser user, IUser manager)
 {
     var praises = _pocoSession.List<Praise>(_numPraisesPerUser).Get();
     foreach (var praise in praises)
     {
         praise.Id = Guid.NewGuid();
         praise.SubjectUser = user.ToSimpleUser();
         praise.CreatedBy = manager.ToSimpleUser();
         Praises.Add(praise);
     }
 }
示例#5
0
 private void AddConcerns(IUser user, IUser manager)
 {
     var concerns = _pocoSession.List<Concern>(_numConcernsPerUser).Get();
     foreach (var concern in concerns)
     {
         concern.Id = Guid.NewGuid();
         concern.SubjectUser = user.ToSimpleUser();
         concern.CreatedBy = manager.ToSimpleUser();
         Concerns.Add(concern);
     }
 }
示例#6
0
        public static void PasswordReset(IUser ou, IDocumentStore store, string password)
        {
            
            var body = GetPasswordResetEmailBody(ou, password)+EmailFooter;
            var notification = new Notification
            {
                About = ou.ToSimpleUser(),
                Body = body,
                Id = IlluminateDatabase.GenerateId<Notification>(),
                SendDate = DateTime.Now,
                Title = "Illuminate Password Reset",
                NotificationRecipients = new[]
                                                                    {
                                                                        new NotificationRecipient
                                                                            {
                                                                                NotificationDeliveryTypes =
                                                                                    NotificationDeliveryTypes.Email,
                                                                                Users = new[]
                                                                                            {
                                                                                                ou.ToSimpleUser()
                                                                                            }
                                                                            }
                                                                    }
            };

            using (var session = store.OpenSession())
            {
                session.Store(notification);
                session.SaveChanges();
            }
        }
示例#7
0
        public static void EmailActivation(IUser ou, IAuthUser au, IDocumentStore store,string password)
        {
            var activationurl = String.Format("{0}://{1}/{2}", "https", ConfigurationManager.AppSettings["ActivationUrl"], au.ActivationCode);

            var body = GetActivationEmailBody(ou, activationurl, au.ActivationCode,password);
            var notification = new Notification
            {
                About = ou.ToSimpleUser(),
                Body = body,
                Id = IlluminateDatabase.GenerateId<Notification>(),
                SendDate = DateTime.Now,
                Title = "Illuminate Account Activation Code",
                NotificationRecipients = new[]
                                                                    {
                                                                        new NotificationRecipient
                                                                            {
                                                                                NotificationDeliveryTypes =
                                                                                    NotificationDeliveryTypes.Email,
                                                                                Users = new[]
                                                                                            {
                                                                                                ou.ToSimpleUser()
                                                                                            }
                                                                            }
                                                                    }
            };

            using (var session = store.OpenSession())
            {
                session.Store(notification);
                session.SaveChanges();
            }
        }
        private Reward GenerateAReward(IUser user, Random rand)
        {
            
            var now = DateTime.UtcNow.Date;
            var date = RandomDate(rand, now.AddDays(0 - _config.DaysHistory), now);
            var possibleComments = _config.RewardsConfig.PotentialComments;
            var toSkip = rand.Next(0, _possibleAttributes.Count() );
            var toTake = rand.Next(1, _possibleAttributes.Count());
            var reward = new Reward()
            {
  
                Id = IlluminateDatabase.GenerateId<Reward>(),
                Attributes = _possibleAttributes.Skip(toSkip).Take(toTake).ToList(),
                ConsolidatedCompletionDate = date,
                Date = date,
                Message =FormatComment(  possibleComments.ElementAt(rand.Next(0,possibleComments.Count()-1)),user),
                SubjectUser = user.ToSimpleUser(),
                RewardGiver = _config.Users.Where(u=>u.Id!=user.Id).ElementAt(rand.Next(0,_config.Users.Count()-1)).ToSimpleUser(),
                Points = rand.Next(_config.RewardsConfig.MinPoints,_config.RewardsConfig.MaxPoints)
            };

            return reward;
        }
示例#9
0
 /// <summary>
 /// Convert a User into an Invitee with no response status. 
 /// </summary>
 /// <param name="u"></param>
 /// <returns></returns>
 public static Invitee FromUser(IUser u)
 {
     return FromSimpleUser(u.ToSimpleUser()); 
 }
        private Concern GenerateAConcern(IUser user, Random rand)
        {
            var manager = user.Relationships.FirstOrDefault(r => r.RelationshipName == "LineManager");
            if (manager == null)
            {
                return null;
            }
            var now = DateTime.UtcNow.Date;
            var date = RandomDate(rand, now.AddDays(0 - _config.DaysHistory), now);
            var concern = new Concern()
            {
                Comment =FormatComment(
                    _config.ConcernConfig.PotentialComments.ElementAt(rand.Next(0,
                                                                        _config.ConcernConfig.PotentialComments
                                                                               .Count() )),user),
                CreatedBy = manager,
                Id = IlluminateDatabase.GenerateId<Concern>(),
                Severity = rand.Next(Concern.Min, Concern.Max),
                ConsolidatedCompletionDate = date,
                EventDate = date,
                SubjectUser = user.ToSimpleUser()
            };

            return concern;
        }
        private Praise GenerateAPraise(IUser user,Random rand)
        {
            var manager = user.Relationships.FirstOrDefault(r => r.RelationshipName == "LineManager");
            if (manager == null)
            {
                return null;
            }
            var now = DateTime.UtcNow.Date;
            var date = RandomDate(rand, now.AddDays(0 - _config.DaysHistory), now);
            var praise = new Praise
                             {
                                 Comment =FormatComment( _config.PraiseConfig.PotentialComments.ElementAt(rand.Next(0,
                                                                                         _config.PraiseConfig.PotentialComments
                                                                                                .Count() - 1)),user)
                                    ,
                                 CreatedBy = manager,
                                 Id = IlluminateDatabase.GenerateId<Praise>(),
                                 Level = rand.Next(Praise.Min, Praise.Max+1),
                                    ConsolidatedCompletionDate = date,
                                    EventDate = date,
                                    SubjectUser = user.ToSimpleUser()
                             };

           return praise;
        }
        private Leave GenerateALeave(bool isCurrent, IUser user,Random rand)
        {

            var manager = user.Relationships.FirstOrDefault(r => r.RelationshipName == "LineManager");
            if (manager == null)
            {
                return null;
            }
            var leave = new Leave
            {
                CurrentProcessOwner = manager,
                Id = IlluminateDatabase.GenerateId<Leave>(),
                Title = "Annual Leave",
                Subject = user.ToSimpleUser(),
                UserCreatedProcess = manager,
                Summary = "Off to the coast!",
                LeaveType = _leaveType
            };
            
            var now = DateTime.UtcNow.Date;
            if (isCurrent)
            {
                leave.StartOfProcess = RandomDate(rand, now.AddDays(0 - _config.LeaveConfig.MaxDurationDays), now);
                leave.ConsolidatedCompletionDate = now;
            }
            else
            {
                var startDate = RandomDate(rand, now.AddDays(0 - _config.DaysHistory), now);
                var endDate = startDate.AddDays(rand.Next(1, _config.LeaveConfig.MaxDurationDays));
                if (endDate >= now)
                    endDate = now.AddDays(-1);
                leave.ConsolidatedCompletionDate = endDate;
                leave.EndOfProcess = endDate;
                leave.StartOfProcess = startDate;
            }
            leave.Approval = new Approval {ApprovalDate = leave.StartOfProcess.AddDays(-5), ApprovedBy = manager};
            return leave;
        }
        private Task GenerateATask(IUser user, Random rand)
        {
            var manager = user.Relationships.FirstOrDefault(r => r.RelationshipName == "LineManager");
            if (manager == null)
            {
                return null;
            }
            var now = DateTime.UtcNow.Date;
            var dueDate = RandomDate(rand, now.AddDays(0 - 10), now);
            var commentNum = rand.Next(0, _config.TasksConfig.PossibleTitles.Count());
            var task = new Task
                           {
                               AssignedUsers = new List<SimpleUser> {manager},
                               ConsolidatedAssignees = new List<SimpleUser> {manager},
                               CreatedBy = user.ToSimpleUser(),
                               DueDate = dueDate,
                               Id = IlluminateDatabase.GenerateId<Task>(),
                               Title =FormatCommentFullName(_config.TasksConfig.PossibleTitles.ElementAt(commentNum),user) ,

                               Description = FormatCommentFullName(_config.TasksConfig.PossibleDescriptions.ElementAt(commentNum), user),
                               ConsolidatedCompletionDate = now

                           };
            
            

            return task;
        }
        private Sickness GenerateASickness(bool isCurrent,IUser user,Random rand)
        {
            
            var sicknessReason = _sicknessClassification.GetRandomReason(rand);
            var manager = user.Relationships.FirstOrDefault(r => r.RelationshipName == "LineManager");
            if (manager == null)
            {
                return null;
            }
            var sickness = new Sickness
                               {
                                   CurrentProcessOwner = manager,
                                   Id = IlluminateDatabase.GenerateId<Sickness>(),
                                   SicknessReason = SicknessReasonSimple.Create(sicknessReason),
                                   Subject = user.ToSimpleUser(),
                                   UserCreatedProcess = manager,
                                   Title = sicknessReason.FullName,
                                   Summary = sicknessReason.Description


                               };
            var now = DateTime.UtcNow.Date;
            if (isCurrent)
            {
                sickness.StartOfProcess = RandomDate(rand, now.AddDays(0 - _config.SicknessConfig.MaxDurationDays), now);
                sickness.ConsolidatedCompletionDate = now;
            }
            else
            {
                var startDate = RandomDate(rand, now.AddDays(0 - _config.DaysHistory), now);
                var endDate = startDate.AddDays(rand.Next(1, _config.SicknessConfig.MaxDurationDays));
                if (endDate >= now)
                    endDate = now.AddDays(-1);
                sickness.ConsolidatedCompletionDate = endDate;
                sickness.EndOfProcess = endDate;
                sickness.StartOfProcess = startDate;
            }
            
            return sickness;
        }