public bool Move(ProjectWorkflow.Trigger trigger) { return(_workflow.TryFireTrigger(trigger)); }
protected void SendMailFromDb(Project project, dynamic model, ProjectWorkflow.Trigger trigger, UserType userType) { var template = Repository.GetOne <MailTemplate>(t => t.Trigger == trigger && t.UserType == userType); if (template == null) { template = new MailTemplate { UserType = userType, Trigger = trigger, Title = "Шаблон письма отсутствует", Body = string.Format("Необходимо добавить шаблон письма для {0} пользователя на {1} событие", userType, trigger) }; } if (template.UserType == UserType.Admin) { string[] users = RoleProvider.GetUsersInRole("Admin"); foreach (var userName in users) { Users user = Repository.GetOne <Users>(u => u.Username == userName); if (user != null && user.NotificationTypeList.Contains(project.GetType().Name)) { Email .From("*****@*****.**") .UsingClient(Client) .To(user.Email) .Subject(template.Title) .UsingTemplate(template.Body, model) .Send(); _protalNotification.PushNotificate(new NotificationQueue { IsRead = false, NotificationTime = DateTime.Now, NotificationTitle = template.Title, NotigicationBody = template.Body, UserName = user.Username }); } } } if (template.UserType == UserType.Investor) { string investorMail = project.InvestorUser; if (string.IsNullOrEmpty(investorMail)) { investorMail = project.Responses.Last().InvestorEmail; } Email .From("*****@*****.**") .UsingClient(Client) .To(investorMail) .Subject(template.Title) .UsingTemplate(template.Body, model) .Send(); _protalNotification.PushNotificate(new NotificationQueue { IsRead = false, NotificationTime = DateTime.Now, NotificationTitle = template.Title, NotigicationBody = template.Body, UserName = project.Responses.Last().InvestorEmail }); } if (template.UserType == UserType.User) { string[] users = RoleProvider.GetUsersInRole("User"); foreach (var userName in users) { MembershipUser user = Membership.GetUser(userName, false); if (user != null) { Email .From("*****@*****.**") .UsingClient(Client) .To(user.Email) .Subject(template.Title) .UsingTemplate(template.Body, model) .Send(); _protalNotification.PushNotificate(new NotificationQueue { IsRead = false, NotificationTime = DateTime.Now, NotificationTitle = template.Title, NotigicationBody = template.Body, UserName = user.UserName }); } } } }
public bool IsMoveablde(ProjectWorkflow.Trigger trigger) { return(_workflow.CanFire(trigger)); }