public async Task <ActionResult> AssignDevice([FromBody] DeviceAssignmentWizard deviceToAssign) { var device = await _uow.Devices.GetDeviceById(deviceToAssign.Id); if (device.IsEmptyObject()) { return(NotFound()); } device.AssignedTo = deviceToAssign.AssignedTo; device.PurposeId = deviceToAssign.PurposeId; await _uow.Devices.AssignDevice(device); if (!string.IsNullOrEmpty(deviceToAssign.NoteBody)) { var deviceNote = new Note { DeviceId = deviceToAssign.Id, Body = deviceToAssign.NoteBody }; await _uow.Notes.CreateNote(deviceNote); } var assignmentHistory = new AssignmentHistory { DeviceId = device.Id, Body = $"Assigned To: {device.AssignedTo}" }; await _uow.AssignmentHistory.CreateAssignmentHistory(assignmentHistory); return(CreatedAtRoute("GetHardwareById", new { id = device.Id, device })); }
public override bool PerformAction(Assignment assignment, Person currentPerson) { try { assignment.WorkerPersonId = assignment.RequesterPersonId; assignment.Save("AssignRequesterAsWorker", null); AssignmentHistory history = new AssignmentHistory(); history.AssignmentId = assignment.AssignmentId; history.Action = "Assigned to " + assignment.Worker.FullName; history.Save("AssignRequesterAsWorker"); if (assignment.WorkerPersonId != -1 && Boolean.Parse(NotifyWorkerSetting)) { AssignmentEntryWorkerEmail email = new AssignmentEntryWorkerEmail(); if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty) { email.Template.Sender = currentPerson.FullName; email.Template.SenderEmail = currentPerson.Emails.FirstActive; } email.Send(assignment); } return(true); } catch (System.Exception ex) { assignment.AddNote("Exception", ex.Message, false, null, "AssignRequesterAsWorker"); return(false); } }
public async Task <ActionResult> UnassignDevice([FromBody] Device deviceToUnassign) { if (deviceToUnassign.IsObjectNull()) { return(BadRequest("Object is null")); } if (string.IsNullOrEmpty(deviceToUnassign.AssignedTo)) { return(BadRequest("Assigned To Field Required")); } var hardware = await _uow.Devices.GetDeviceById(deviceToUnassign.Id); if (hardware.IsEmptyObject()) { return(NotFound()); } await _uow.Devices.UnassignDevice(deviceToUnassign); var assignmentHistory = new AssignmentHistory { DeviceId = deviceToUnassign.Id, Body = "Unassigned" }; await _uow.AssignmentHistory.CreateAssignmentHistory(assignmentHistory); return(CreatedAtRoute("GetDeviceById", new { id = deviceToUnassign.Id, deviceToUnassign })); }
public async Task <ActionResult> AssignHardware([FromBody] Hardware hardwareToAssign) { if (hardwareToAssign.IsObjectNull()) { return(BadRequest("Object is null")); } if (string.IsNullOrEmpty(hardwareToAssign.AssignedTo)) { return(BadRequest("Assigned To Field Required")); } var hardware = await _uow.Hardware.GetHardwareById(hardwareToAssign.Id); if (hardware.IsEmptyObject()) { return(NotFound()); } await _uow.Hardware.AssignHardware(hardwareToAssign); var assignmentHistory = new AssignmentHistory { HardwareId = hardwareToAssign.Id, Body = $"Assigned To: {hardwareToAssign.AssignedTo}" }; await _uow.AssignmentHistory.CreateAssignmentHistory(assignmentHistory); return(CreatedAtRoute("GetHardwareById", new { id = hardwareToAssign.Id, hardwareToAssign })); }
private void CreateAssignmentHistory(Assignment assignment) { var wfDef = _workflowDefinitionRepository.GetById(assignment.WorkflowDefinitionId); // Create a new assignment history record, clone most of its fields // and save it into the database. AssignmentHistory assignmentHistory = new AssignmentHistory { Name = assignment.Name, EntityId = assignment.EntityId, EntityType = assignment.EntityType, Number = assignment.Number, Description = assignment.Description, Priority = assignment.Priority, AssignmentType = assignment.AssignmentType, AssignmentAmount = assignment.AssignmentAmount, Comment = assignment.Comment, TriggeredAction = assignment.TriggeredAction, ExpectedStartDateTime = assignment.ExpectedStartDateTime, DueDateTime = assignment.DueDateTime, WorkflowInstanceId = assignment.WorkflowInstanceId, WorkflowDefinitionId = assignment.WorkflowDefinitionId, WorkflowDefinitionName = wfDef.Name, WorkflowVersion = assignment.WorkflowVersion, AssignedUsers = string.Join(";", assignment.Users.Select(u => u.Name)) }; _assignmentHistoryRepository.Insert(assignmentHistory); }
public Task <List <Assignment> > GetAssignmentFromHistory(AssignmentHistory assignmentHistory, CancellationToken cancellationToken) { return(Task.Factory.StartNew(() => new List <Assignment> { new Assignment { Id = assignmentHistory.AssignmentId } })); }
public Task LoadAssignmentFromHistory(AssignmentHistory assignmentHistory) { return(service .GetAssignmentFromHistory(assignmentHistory) .ContinueOnCurrentThread(t => { PastAssignment = t.Result.FirstOrDefault(); PastAssignment.IsHistory = true; return t.Result; })); }
public SummaryHistoryActivity() { historyViewModel = ServiceContainer.Resolve <HistoryViewModel> (); itemViewModel = ServiceContainer.Resolve <ItemViewModel> (); laborViewModel = ServiceContainer.Resolve <LaborViewModel> (); photoViewModel = ServiceContainer.Resolve <PhotoViewModel> (); expenseViewModel = ServiceContainer.Resolve <ExpenseViewModel> (); documentViewModel = ServiceContainer.Resolve <DocumentViewModel> (); menuViewModel = ServiceContainer.Resolve <MenuViewModel> (); assignmentHistory = historyViewModel.SelectedAssignmentHistory; }
/// <summary> /// Sets up the history record for this cell /// </summary> public void SetHistory(AssignmentHistory history, bool enabled) { //Any 1-time settings if (!loaded) { number.TextColor = length.TextColor = description.TextColor = date.TextColor = Theme.LabelColor; phone.IconImage = Theme.IconPhone; phoneIcon.Image = Theme.IconPhoneDark; address.IconImage = Theme.Map; address.UserInteractionEnabled = false; loaded = true; } SelectionStyle = history.Type == AssignmentHistoryType.PhoneCall || !enabled ? UITableViewCellSelectionStyle.None : UITableViewCellSelectionStyle.Blue; date.Text = history.Date.ToShortDateString(); phone.TopLabel.Text = history.ContactName; phone.BottomLabel.Text = history.ContactPhone; if (history.Type == AssignmentHistoryType.PhoneCall) { number.Hidden = address.Hidden = true; length.Hidden = description.Hidden = phoneIcon.Hidden = false; length.Text = "Length: " + history.CallLength.ToString(); description.Text = history.CallDescription; } else { number.Hidden = address.Hidden = false; length.Hidden = description.Hidden = phoneIcon.Hidden = true; number.Text = "#" + history.JobNumber; address.TopLabel.Text = history.Address; address.BottomLabel.Text = string.Format("{0}, {1} {2}", history.City, history.State, history.Zip); } title.Text = history.CompanyName; }
public virtual string Reassign(long entityId, string entityType, long[] selectedIds) { string assignedUsers = ""; var assignment = _assignmentRepository.GetAll() .Where(a => a.EntityId == entityId && a.EntityType == entityType).FirstOrDefault(); if (assignment != null) { assignment.Users.Clear(); foreach (var id in selectedIds) { var user = _userRepository.GetById(id); assignment.Users.Add(user); } _assignmentRepository.UpdateAndCommit(assignment); //Send message var wfEntity = this._dbContext.GetByEntityIdAndType(entityId, entityType) as WorkflowBaseEntity; _messageService.SendMessage(wfEntity, "Reassign", assignment.Users.ToList(), null); //Log history var wfDef = _workflowDefinitionRepository.GetById(assignment.WorkflowDefinitionId); AssignmentHistory assignmentHistory = new AssignmentHistory { Name = assignment.Name, EntityId = assignment.EntityId, EntityType = assignment.EntityType, Number = assignment.Number, Description = assignment.Description, Priority = assignment.Priority, AssignmentType = assignment.AssignmentType, AssignmentAmount = assignment.AssignmentAmount, Comment = "", TriggeredAction = "Reassign", ExpectedStartDateTime = assignment.ExpectedStartDateTime, DueDateTime = assignment.DueDateTime, WorkflowInstanceId = assignment.WorkflowInstanceId, WorkflowDefinitionId = assignment.WorkflowDefinitionId, WorkflowDefinitionName = wfDef.Name, WorkflowVersion = assignment.WorkflowVersion, AssignedUsers = string.Join(";", assignment.Users.Select(u => u.Name)) }; _assignmentHistoryRepository.InsertAndCommit(assignmentHistory); assignedUsers = string.Join(";", assignment.Users.Select(u => u.Name)); } return(assignedUsers); }
public override bool PerformAction(Assignment assignment, Person currentPerson) { try { CustomFieldValue customField = assignment.FieldValues.FindById(Convert.ToInt32(FieldSetting)); if (customField != null) { if (customField.SelectedValue.Trim() != string.Empty) { assignment.WorkerPersonId = Int32.Parse(customField.SelectedValue.Trim()); assignment.Save("AssignFieldAsWorker", null); AssignmentHistory history = new AssignmentHistory(); history.AssignmentId = assignment.AssignmentId; history.Action = "Assigned to " + assignment.Worker.FullName; history.Save("AssignFieldAsWorker"); if (assignment.RequesterPersonId != -1 && Boolean.Parse(NotifyRequesterSetting)) { AssignmentEntryRequesterEmail email = new AssignmentEntryRequesterEmail(); if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty) { email.Template.Sender = currentPerson.FullName; email.Template.SenderEmail = currentPerson.Emails.FirstActive; } email.Send(assignment); } if (assignment.WorkerPersonId != -1 && Boolean.Parse(NotifyWorkerSetting)) { AssignmentEntryWorkerEmail email = new AssignmentEntryWorkerEmail(); if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty) { email.Template.Sender = currentPerson.FullName; email.Template.SenderEmail = currentPerson.Emails.FirstActive; } email.Send(assignment); } } } return(true); } catch (System.Exception ex) { assignment.AddNote("Exception", ex.Message, false, null, "AssignFieldAsWorker"); return(false); } }
public override bool PerformAction(Assignment assignment, Person currentPerson) { try { // Find the custom field, then load the person. CustomFieldValue customField = assignment.FieldValues.FindById(int.Parse(FieldSetting)); if (customField != null && customField.SelectedValue.Trim() != string.Empty) { int personID = int.Parse(customField.SelectedValue.Trim()); PersonHistory history = new PersonHistory(); history.PersonID = personID; history.HistoryType = new Lookup(SystemLookup.PersonHistoryType_User); history.Text = assignment.ResolutionText; history.SystemHistory = false; history.Save(int.Parse(OrganizationIDSetting), assignment.Worker.FullName); Person person = new Person(personID); AssignmentHistory assignmentHistory = new AssignmentHistory(); assignmentHistory.AssignmentId = assignment.AssignmentId; assignmentHistory.Action = "Resolution copied to " + person.FullName + " as a note"; assignmentHistory.Save("AddResolutionToPersonNote"); // This will let the worker view the person note: history.ApplyPersonSecurity(assignment.WorkerPersonId, assignment.Worker.FullName); // Now, we'll apply the security template if one was selected. if (SecurityTemplateSetting != string.Empty) { history.ApplyTemplateSecurity(int.Parse(SecurityTemplateSetting)); } } return(true); } catch (System.Exception ex) { assignment.AddNote("Exception", ex.Message, false, null, "AssignRequesterAsWorker"); return(false); } }