public void SaveProjectDate(long idProject, DateTime?editStartDate, DateTime?editDeadLine) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else if (editStartDate != View.PreviousStartDate || editDeadLine != View.PreviousDeadline) { dtoField <DateTime?> startDate = new dtoField <DateTime?>(); dtoField <DateTime?> endDate = new dtoField <DateTime?>(); dtoField <DateTime?> deadLine = new dtoField <DateTime?>(); dtoProject project = Service.SetProjectDates(idProject, editStartDate, editDeadLine, ref startDate, ref endDate, ref deadLine); if (project != null) { View.DisplaySavedDates(startDate, endDate, deadLine); View.SendUserAction(project.IdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectSavedStartDateDeadline); } else { View.DisplayErrorSavingDates(); View.SendUserAction(project.IdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectSavingErrorStartDateDeadline); } } }
private void AddActivities(AddActivityAction action, long idProject, long idActivity, Int32 number, Boolean linked, Int32 children, List <dtoLiteMapActivity> activities) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { dtoField <DateTime?> startDate = new dtoField <DateTime?>(); dtoField <DateTime?> endDate = new dtoField <DateTime?>(); dtoField <DateTime?> deadLine = new dtoField <DateTime?>(); List <dtoMapActivity> dbActivities = Service.AddActivitiesToProject(action, idProject, idActivity, View.GetDefaultActivityName(), number, linked, children, activities, View.InEditStartDate, View.InEditDeadline, ref startDate, ref endDate, ref deadLine, View.UnknownUser); if (dbActivities != null && dbActivities.Where(a => a.IsNew).Any()) { View.DisplayActivitiesAdded(); View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectMapAddedActivities); } else { View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectMapAddingActivityErrors); View.DisplayUnableToAddActivities(); } if (dbActivities != null) { View.LoadActivities(dbActivities, startDate, endDate, deadLine); } } }
public void SaveActivity(long idProject, long idActivity, dtoActivity activity, List <long> idResources, List <dtoActivityLink> links, List <dtoActivityCompletion> assignments, Boolean isCompleted, DateTime?prStartDate = null, DateTime?prEndDate = null, DateTime?prDeadline = null) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { dtoField <DateTime?> startDate = new dtoField <DateTime?>() { Init = prStartDate }; dtoField <DateTime?> endDate = new dtoField <DateTime?>() { Init = prEndDate }; dtoField <DateTime?> deadLine = new dtoField <DateTime?>() { Init = prDeadline }; ActivityEditingErrors errors = Service.SaveActivity(idProject, idActivity, activity, idResources, links, assignments, isCompleted, ref startDate, ref endDate, ref deadLine); if (errors == ActivityEditingErrors.None) { View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ActivitySaved); View.DisplayActivitySaved(idActivity, startDate, endDate, deadLine); } else { View.DisplayUnableToSaveActivity(); View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ActivityUnableToSave); } } }
public void EditActivity(long idProject, long idActivity, List <dtoLiteMapActivity> activities) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { Boolean saved = false; long updated = 0; long alreadyModified = 0; dtoField <DateTime?> startDate = new dtoField <DateTime?>(); dtoField <DateTime?> endDate = new dtoField <DateTime?>(); dtoField <DateTime?> deadLine = new dtoField <DateTime?>(); long toUpdate = activities.Where(a => a.InEditMode).Count(); if (toUpdate > 0) { List <dtoMapActivity> dbActivities = Service.SaveActivities(idProject, activities, View.InEditStartDate, View.InEditDeadline, ref startDate, ref endDate, ref deadLine, ref updated, ref alreadyModified, View.UnknownUser); if (updated > 0 && updated == activities.Where(a => a.InEditMode).Count()) { saved = true; if (dbActivities == null) { View.DisplaySavedActivities(); } else { View.DisplaySavedActivities(dbActivities.Where(a => a.InEditPredecessorsMode && a.Status == FieldStatus.error).Any(), dbActivities.Where(a => a.InEditPredecessorsMode && a.Status == FieldStatus.errorfatherlinked).Any(), dbActivities.Where(a => a.InEditPredecessorsMode && a.Status == FieldStatus.errorsummarylinked).Any()); } View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectMapSavedActivities); if (dbActivities != null) { View.LoadActivities(dbActivities, startDate, endDate, deadLine); } } else if (!activities.Where(a => a.InEditMode).Any()) { View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectMapErrorSavingActivities); View.DisplaySavingActivitiesErrors(activities.Where(a => a.InEditMode).Count(), updated, alreadyModified); } } else { saved = true; } if (saved) { if (Service.GetActivity(idActivity) != null) { View.InitializeActivityControl(idActivity); } else { View.DisplayRemovedActivity(); } } } }
public void MoveActivityTo(long idProject, long idActivity, long idParent, List <dtoLiteMapActivity> activities, ModuleProjectManagement.ActionType action = ModuleProjectManagement.ActionType.None) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { dtoField <DateTime?> startDate = new dtoField <DateTime?>(); dtoField <DateTime?> endDate = new dtoField <DateTime?>(); dtoField <DateTime?> deadLine = new dtoField <DateTime?>(); if (action == ModuleProjectManagement.ActionType.None) { action = ModuleProjectManagement.ActionType.ActivityToChild; } Boolean moved = false; List <dtoMapActivity> dbActivities = Service.MoveActivityTo(idProject, idActivity, idParent, activities, View.InEditStartDate, View.InEditDeadline, ref startDate, ref endDate, ref deadLine, View.UnknownUser, ref moved); if (moved) { if (dbActivities == null) { View.DisplayActivityMoved(); } else { View.DisplayActivityMoved(dbActivities.Where(a => a.InEditPredecessorsMode && a.Status == FieldStatus.error).Any(), dbActivities.Where(a => a.InEditPredecessorsMode && a.Status == FieldStatus.errorfatherlinked).Any(), dbActivities.Where(a => a.InEditPredecessorsMode && a.Status == FieldStatus.errorsummarylinked).Any()); } View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ActivityToChild); } else { View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ActivityToChildErrors); View.DisplayUnableToMoveActivity(); } if (dbActivities != null) { View.LoadActivities(dbActivities, startDate, endDate, deadLine); } } }
public void SavedActivity(long idProject, long idActivity, List <dtoLiteMapActivity> activities, dtoField <DateTime?> startDate, dtoField <DateTime?> endDate, dtoField <DateTime?> deadLine) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { foreach (dtoLiteMapActivity vActivity in activities.Where(a => !String.IsNullOrEmpty(a.Current.Predecessors) && !String.IsNullOrEmpty(a.Previous.Predecessors))) { vActivity.UpdateIdPredecessors(activities); } List <dtoMapActivity> dbActivities = Service.GetActivities(idProject, View.ProjectIdCommunity, CurrentIdModule, View.UnknownUser, activities); if (dbActivities == null) { View.DisplayErrorGetActivitiesFromDB(); View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectMapErrorFromDb); } else { View.DisplayActivitySaved(dbActivities.Where(a => a.IdActivity == idActivity).FirstOrDefault(), startDate, endDate, deadLine); View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ProjectMapForEditing); View.LoadActivities(dbActivities); } } }