public GenericServiceResult MoveTask(string userId, int boardId, int taskId, int columnId) { try { bool isUserCanChangeTask = CanUserChangeTask(userId, boardId, taskId); if (!isUserCanChangeTask) { return(GenericServiceResult.AccessDenied); } Task task = unitOfWork.Tasks.Get(taskId); task.ColumnId = columnId; unitOfWork.Tasks.Update(task); int projectId = unitOfWork.Boards.Get(boardId).ProjectId; Project project = unitOfWork.Projects.Get(projectId); Column column = unitOfWork.Columns.Get(columnId); NotificationMessage message = new NotificationMessage { Title = $"{project.Title}", Message = $"Task {task.Title} was moved to column {column.Title}", Initiator = userId, SendTo = task.CreatorId }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public GenericServiceResult RemoveUserFromProject(string userId, string userIdToRemove, int projectId) { try { bool canUserChangeProject = CanUserChangeProject(userId, projectId); if (!canUserChangeProject) { return(GenericServiceResult.AccessDenied); } ProjectUser projectUser = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == projectId && p.UserId == userIdToRemove); unitOfWork.ProjectUser.Delete(projectUser.Id); string projectTitle = unitOfWork.Projects.Get(projectId).Title; NotificationMessage message = new NotificationMessage { Title = $"{projectTitle}", Message = "You were removed from project.", Link = null, ObjectId = projectId, Initiator = userId, SendTo = userIdToRemove }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public override void Execute(Cmdline cmd) { try { var exec = new CmdExecutor(); if (exec.IsConfiguration(cmd.Parameters)) { exec.Configure(cmd.Parameters); } if (exec.IsList(cmd.Parameters)) { var resul = exec.List(); } else { exec.Execute(cmd); Notifyer.NotifyInfo($"Evernote: note created."); } } catch (Exception ex) { Logger.Error($"Cannot execute EN plugin: {ex.Message}", ex); Notifyer.NotifyError($"Cannot execute EN plugin: {ex.Message}"); } }
protected override ExecutionResult DoExecute(string arg) { if (string.IsNullOrWhiteSpace(arg)) { Notifyer.NotifyWarning($"Cannot switch to an empty session!"); return(ExecutionResult.SuccessHide); } else { var s = DataService.GetSession(arg); if (s != null) { var aps = SettingsService.Get(); aps.SessionId = s.Id; SettingsService.Save(aps); Log.Info($"Switched to Session '{s.Name}'"); Notifyer.NotifyInfo($"Switched to Session '{s.Name}'"); } else { Notifyer.NotifyWarning($"Session '{arg}' does not exist."); } return(ExecutionResult.SuccessHide); } }
public CoinMarketTask(IRepository <User> userRepository, Notifyer notifyer, HttpClientWrapper client, CurrencyService currencyService, ILogger <CoinMarketTask> logger, IRepository <Alert> alertRepository) { _userRepository = userRepository; _notifyer = notifyer; _client = client; _currencyService = currencyService; _logger = logger; _alertRepository = alertRepository; }
private void NavigateUser() { if (PluginContext.Host.Navigate(this.ManageUserView)) { this.ManageUserView.As <ManageUserViewModel>().Refresh(); this.displayed = PageEventArgs.DisplayedPage.UserManager; Notifyer.OnShowing(this, PageEventArgs.DisplayedPage.UserManager); this.ContextualMenu.IsVisible = true; this.ContextualMenu.TabDataCollection[0].IsSelected = true; } }
public GenericServiceResult UpdateBoardSettings(BoardSettingsViewModel model, string userId) { try { bool isUserCanChangeBoard = CanUserChangeBoard(userId, model.BoardId); if (!isUserCanChangeBoard) { return(GenericServiceResult.AccessDenied); } Board board = unitOfWork.Boards.Get(model.BoardId); BoardSettings boardSettings = unitOfWork.BoardSettings.Get(model.BoardId); board.Title = model.Title; boardSettings.AccessToChangeBoard = (int)model.AccessToChangeBoard; boardSettings.AccessToChangeTask = (int)model.AccessToChangeTask; boardSettings.AccessToCreateTask = (int)model.AccessToCreateTask; boardSettings.AccessToDeleteTask = (int)model.AccessToDeleteTask; unitOfWork.BoardSettings.Update(boardSettings); unitOfWork.Boards.Update(board); foreach (var column in model.Columns) { Column databaseColumn = unitOfWork.Columns.Get(column.Id); databaseColumn.Position = column.Position; databaseColumn.Title = column.Title; unitOfWork.Columns.Update(databaseColumn); } int projectId = unitOfWork.Projects.Get(board.ProjectId).Id; string creatorId = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == projectId && p.Role == (int)ProjectRoles.Administrator).UserId; string projectTitle = unitOfWork.Projects.Get(projectId).Title; NotificationMessage message = new NotificationMessage { Title = $"{projectTitle}", Message = $"Board {board.Title} settings were changed", Initiator = userId, SendTo = creatorId }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public GenericServiceResult AddUserToProject(string userId, string userEmailToAdd, int projectId) { try { bool canUserChangeProject = CanUserChangeProject(userId, projectId); if (!canUserChangeProject) { return(GenericServiceResult.AccessDenied); } User existingUser = unitOfWork.Users.GetFirstOrDefaultWhere(u => u.Email == userEmailToAdd); if (existingUser == null) { return(GenericServiceResult.Error); } string userIdToAdd = existingUser.Id; ProjectUser existingProjectUser = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.UserId == userIdToAdd && p.ProjectId == projectId); if (existingProjectUser != null) { return(GenericServiceResult.Error); } ProjectUser projectUser = new ProjectUser { ProjectId = projectId, UserId = userIdToAdd, Role = (int)ProjectRoles.Member }; string projectTitle = unitOfWork.Projects.Get(projectId).Title; unitOfWork.ProjectUser.Create(projectUser); NotificationMessage message = new NotificationMessage { Title = $"{projectTitle}", Message = "You were added to project.", Link = null, ObjectId = projectId, Initiator = userId, SendTo = userIdToAdd }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public GenericServiceResult CreateBoard(CreateBoardViewModel model, string userId, int projectId) { try { bool isUserCanCreateBoard = CanUserCreateBoard(userId, projectId); if (!isUserCanCreateBoard) { return(GenericServiceResult.AccessDenied); } ProjectUser projectUser = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == projectId && p.UserId == userId); BoardSettings boardSettings = new BoardSettings { AccessToChangeTask = (int)model.AccessToChangeTask, AccessToCreateTask = (int)model.AccessToCreateTask, AccessToDeleteTask = (int)model.AccessToDeleteTask, AccessToChangeBoard = (int)model.AccessToChangeBoard }; Board board = new Board { Title = model.Title, Settings = boardSettings, ProjectId = projectId, CreatorId = userId }; unitOfWork.Boards.Create(board); string creatorId = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == projectId && p.Role == (int)ProjectRoles.Administrator).UserId; string projectTitle = unitOfWork.Projects.Get(projectId).Title; NotificationMessage message = new NotificationMessage { Title = $"{projectTitle}", Message = $"Board {board.Title} was created", Initiator = userId, SendTo = creatorId }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public GenericServiceResult DeleteTask(string userId, int taskId, int boardId) { try { bool isUserCanDeleteTask = CanUserDeleteTask(userId, boardId, taskId); if (!isUserCanDeleteTask) { return(GenericServiceResult.AccessDenied); } string taskTitle = unitOfWork.Tasks.Get(taskId).Title; string taskCreator = unitOfWork.Tasks.Get(taskId).CreatorId; string taskAssignee = unitOfWork.Tasks.Get(taskId).AssigneeId; unitOfWork.Attachments.Delete(a => a.TaskId == taskId); unitOfWork.Tasks.Delete(taskId); int projectId = unitOfWork.Boards.Get(boardId).ProjectId; Project project = unitOfWork.Projects.Get(projectId); NotificationMessage message = new NotificationMessage { Title = $"{project.Title}", Message = $"Task {taskTitle} was deleted", Initiator = userId, SendTo = taskCreator, AdditionalSendTo = taskAssignee, AdditionalSendToMessage = new NotificationMessage { Title = $"{project.Title}", Message = $"Task {taskTitle} was deleted", Initiator = userId, SendTo = taskAssignee, } }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public GenericServiceResult SaveProjectSettings(string userId, ProjectSettingsViewModel model) { try { int projectId = model.Id; bool canUserChangeProject = CanUserChangeProject(userId, projectId); if (!canUserChangeProject) { return(GenericServiceResult.AccessDenied); } Project project = unitOfWork.Projects.Get(projectId); string projectTitleBeforeChanging = project.Title; ProjectSettings projectSettings = unitOfWork.ProjectSettings.Get(projectId); project.Title = model.Title; project.About = model.About; projectSettings.AccessToChangeProject = (int)model.AccessToChangeProject; projectSettings.AccessToCreateBoard = (int)model.AccessToCreateBoard; projectSettings.AccessToDeleteBoard = (int)model.AccessToDeleteBoard; unitOfWork.ProjectSettings.Update(projectSettings); unitOfWork.Projects.Update(project); string creatorId = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == projectId && p.Role == (int)ProjectRoles.Administrator).UserId; NotificationMessage message = new NotificationMessage { Title = $"{projectTitleBeforeChanging}", Message = "Project settings were updated.", Link = null, ObjectId = projectId, Initiator = userId, SendTo = creatorId }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public GenericServiceResult DeleteBoard(string userId, int boardId) { try { Board board = unitOfWork.Boards.Get(boardId); int projectId = board.ProjectId; bool isUserCanDeleteBoard = CanUserDeleteBoard(userId, projectId); if (!isUserCanDeleteBoard) { return(GenericServiceResult.AccessDenied); } var result = DeleteColumnsWithoutPermission(boardId); if (result != GenericServiceResult.Success) { return(GenericServiceResult.Error); } unitOfWork.BoardSettings.Delete(board.Id); unitOfWork.Boards.Delete(board.Id); string creatorId = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == projectId && p.Role == (int)ProjectRoles.Administrator).UserId; string projectTitle = unitOfWork.Projects.Get(projectId).Title; NotificationMessage message = new NotificationMessage { Title = $"{projectTitle}", Message = $"Board {board.Title} was deleted", Initiator = userId, SendTo = creatorId }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public void OutputMessageGraphically(string title, string message, NavigationDirection navigationDirection = NavigationDirection.None) { int appearingTime = 100, disappearingTime = 200; switch (Notifyer.TaskbarState) { case TaskbarNotifier.TaskbarStates.appearing: case TaskbarNotifier.TaskbarStates.disappearing: Notifyer.Hide(); Notifyer.Show(title, message, appearingTime, VisualDisplayTime, disappearingTime); break; case TaskbarNotifier.TaskbarStates.visible: Notifyer.TitleText = title; Notifyer.ContentText = message; break; default: Notifyer.Show(title, message, appearingTime, VisualDisplayTime, disappearingTime); break; } }
public override void Execute(Cmdline cmd) { var list = new string[] { "list", "l" }; var parameters = cmd.Parameters.ToLower().Trim(); if (list.Contains(parameters)) { ShowHistory(); } else if (string.IsNullOrWhiteSpace(parameters)) { using (var s = new ClipboardManager()) { s.AddClipboardContent(); ShowHistory(); Notifyer.NotifyInfo("Clipboard content saved."); } } else { Notifyer.NotifyWarning($"Not supported argument '{parameters}'. Use no argument to save clipboard or 'l' or 'list' to see history"); } }
private static void StartUpUI() { Menu = new MainController(); Notifyer = Menu.Notifyer; ReloadUI(); }
public GenericServiceResult CreateTask(CreateTaskViewModel model, string userId) { try { bool isUserCanCreateTask = CanUserCreateTask(userId, model.BoardId); if (!isUserCanCreateTask) { return(GenericServiceResult.AccessDenied); } Task task = new Task { ColumnId = model.ColumnId, Title = model.Title, Content = model.Content, Priority = (int)model.Priority, Severity = (int)model.Severity, Type = (int)model.Type, StartTime = DateTime.Now, AssigneeId = model.AssigneeId, CreatorId = userId }; unitOfWork.Tasks.Create(task); int taskId = task.Id; GenericServiceResult result = UploadAttachment(taskId, model.Attachments); string creatorId = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == model.ProjectId && p.Role == (int)ProjectRoles.Administrator).UserId; string projectTitle = unitOfWork.Projects.Get(model.ProjectId).Title; NotificationMessage message = new NotificationMessage { NotificationType = NotificationType.Changed, Title = $"{projectTitle}", Message = $"Task {task.Title} was created", Initiator = userId, SendTo = creatorId }; Notifyer.Notify(message); if (task.AssigneeId != null) { message = new NotificationMessage { NotificationType = NotificationType.Assigned, Title = $"{projectTitle}", Message = $"You were assigned to task {task.Title}", Initiator = userId, SendTo = task.AssigneeId }; Notifyer.Notify(message); } return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
/// <summary> /// The Main method. /// </summary> /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); if (args == null || args.Length < 2) { log.WarnFormat(Text.Warning_InputParameterMissing); return; } log.DebugFormat(Text.Debug_StartingProcess); string username = args[0]; string password = args[1]; IList<string> hosts = new List<string>(); for (int i = 2; i < args.Length; i++) { hosts.Add(args[i]); } InternetTools tools = new InternetTools(); Dyn dyn = new Dyn(username, password); try { IPAddress currentIP = tools.GetExternalIP(); Notifyer notifyer = new Notifyer( ConfigurationManager.AppSettings["SmtpServer"], int.Parse(ConfigurationManager.AppSettings["SmtpPort"]), ConfigurationManager.AppSettings["SmtpUsername"], ConfigurationManager.AppSettings["SmtpPassword"]); foreach (string hostname in hosts) { log.DebugFormat(Text.Debug_CheckingHost, hostname); try { IPAddress hostIP = tools.ResolveHostnameIP(hostname); if (hostIP.ToString() == currentIP.ToString()) { // Skip the update log.DebugFormat(Text.Debug_SkippingHost, hostname); } else { // Update host IP address log.DebugFormat(Text.Debug_UpdatingHost, hostname, currentIP.ToString()); string result; bool success = dyn.UpdateHostname(hostname, currentIP, out result); if (success) { notifyer.IpChangeNotification( ConfigurationManager.AppSettings["FromEmail"], ConfigurationManager.AppSettings["NotifyEmail"], hostname, currentIP.ToString(), result); } else { notifyer.IpChangeNotification( ConfigurationManager.AppSettings["FromEmail"], ConfigurationManager.AppSettings["NotifyEmail"], hostname, currentIP.ToString(), result); } } } catch (Exception ex) { log.ErrorFormat(Text.Exception_Generic, ex.Message); } } } catch (Exception ex) { log.ErrorFormat(Text.Exception_Generic, ex.Message); } log.DebugFormat(Text.Debug_ProcessCompleted); }
public GenericServiceResult UpdateTask(TaskViewModel model, string userId) { try { bool isUserCanChangeTask = CanUserChangeTask(userId, model.BoardId, model.TaskId); if (!isUserCanChangeTask) { return(GenericServiceResult.AccessDenied); } string creatorId = unitOfWork.Users.GetFirstOrDefaultWhere(u => u.Email == model.CreatorEmail).Id; string assigneId = null; if (model.AssigneeEmail != null) { assigneId = unitOfWork.Users.GetFirstOrDefaultWhere(u => u.Email == model.AssigneeEmail).Id; } if (model.AssigneeId != null) { assigneId = model.AssigneeId; } Task task = unitOfWork.Tasks.Get(model.TaskId); string taskPreviousAssignee = task.AssigneeId; task.Id = model.TaskId; task.Title = model.Title; task.Content = model.Content; task.Priority = (int)model.Priority; task.Severity = (int)model.Severity; task.Type = (int)model.Type; task.ColumnId = model.ColumnId; task.AssigneeId = assigneId; task.CreatorId = creatorId; string taskNewAssingee = taskPreviousAssignee == task.AssigneeId ? "" : task.AssigneeId; unitOfWork.Tasks.Update(task); Project project = unitOfWork.Projects.Get(model.ProjectId); NotificationMessage message = new NotificationMessage { Title = $"{project.Title}", Message = $"Task {task.Title} was changed", Initiator = "", SendTo = task.CreatorId, AdditionalSendTo = taskNewAssingee, AdditionalSendToMessage = new NotificationMessage { Title = $"{project.Title}", Message = $"You were assigned to task {task.Title}", Initiator = userId, SendTo = taskNewAssingee, AdditionalSendTo = taskPreviousAssignee, AdditionalSendToMessage = new NotificationMessage { Title = $"{project.Title}", Message = $"You were unassigned from task {task.Title}", Initiator = userId, SendTo = taskPreviousAssignee } } }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }