/// <summary> /// Create new assignment. Last action executes Create Button, returning to List Tab. /// </summary> /// <param name="emp"></param> /// <param name="wo"></param> /// <param name="wa"></param> /// <returns></returns> public bool workAssignmentCreate(Employer emp, WorkOrder wo, WorkAssignment wa, FluentRecordBase frb) { // Click on the assignment Create Tab WaitThenClickElement(By.Id("wact-" + wo.ID)); //the ID here is the WorkOrder.ID, not the Employer.ID WaitForElement(By.Id(wa.idPrefix + "description")); SelectOption(By.Id(wa.idPrefix + "englishLevelID"), wa.englishLevelID.ToString()); SelectOptionByValue(By.Id(wa.idPrefix + "skillID"), wa.skillID.ToString()); ReplaceElementText(By.Id(wa.idPrefix + "hourlyWage"), wa.hourlyWage.ToString()); ReplaceElementText(By.Id(wa.idPrefix + "hours"), wa.hours.ToString()); if (wa.hourRange.ToString().Length > 0) { SelectOption(By.Id(wa.idPrefix + "hourRange"), wa.hourRange.ToString()); } SelectOption(By.Id(wa.idPrefix + "days"), wa.days.ToString()); ReplaceElementText(By.Id(wa.idPrefix + "description"), wa.description); WaitForElement(By.Id("WO" + wo.ID + "-waCreateBtn")).Click(); Thread.Sleep(1000); wa.ID = getSelectedTabRecordID("WA"); wa.pseudoID = frb.ToServ <Machete.Service.IWorkAssignmentService>().Get(wa.ID).pseudoID; wa.tablabel = "Assignment #: " + System.String.Format("{0,5:D5}-{1,2:D2}", wo.paperOrderNum, wa.pseudoID); WaitForElement(By.Id(wa.idPrefix + "EditTab")); WaitThenClickElement(By.Id("walt-" + wo.ID)); return(true); }
private void ExecuteAssignment(WorkAssignment assignment) { PostAvailability(false); switch (assignment) { case TokenizationAssignment tokenization: ExecuteTokenization(tokenization); break; case NormalizationAssignment normalizaton: ExecuteNormalization(normalizaton); break; case ShutdownAssignment shutdown: ExecuteShutdown(shutdown); break; case ConfigureNormalizationAssignment configuration: ConfigureNormalization(configuration); break; default: throw new InvalidOperationException("Did not recognize the assignment type: " + assignment.GetType()); } PostAvailability(true); }
// GET: Trying to return model public WorkModel GetModel(string workName) { WorksheetEntities entities = new WorksheetEntities(); try { string chosenWorkId = workName; WorkAssignment chosenWorkData = (from cw in entities.WorkAssignments where (cw.Active == true) && (cw.Id_WorkAssignment.ToString() == chosenWorkId) select cw).FirstOrDefault(); WorkModel chosenWorkModel = new WorkModel() { WorkTitle = chosenWorkData.Title, Description = chosenWorkData.Description, Deadline = chosenWorkData.Deadline.Value }; return(chosenWorkModel); } finally { entities.Dispose(); } }
public void SeEmployer_Create_and_Activate_WorkAssignment() { //Arrange Employer _employer1 = frb.CloneEmployer(); WorkOrder _wo = frb.CloneWorkOrder(); WorkAssignment _wa1 = frb.CloneWorkAssignment(); _wo.contactName = ui.RandomString(10); _wo.statusID = frb.ToLookupCache().getByKeys(LCategory.orderstatus, LOrderStatus.Pending); // status = pending // // Create employer ui.employerCreate(_employer1); // Create work order ui.workOrderCreate(_employer1, _wo); // create assignment ui.workAssignmentCreate(_employer1, _wo, _wa1); //Get WA ID and arrange pseudoID information _wa1.workOrder = _wo; _wa1.workOrderID = _wo.ID; // pseudoID needs to be updated; created on save above _wa1.pseudoID = frb.ToServWorkAssignment().Get(_wa1.ID).pseudoID; // Activate assignment ui.workAssignmentActivate(_employer1, _wo, _wa1); // ui.workAssignmentValidate(_employer1, _wo, _wa1); ui.workOrderValidate(_wo); // TODO: Selenium: test duplicate (pseudoID increment is visible in table) // TODO: Selenium: test DispatchOption / Change Worker dialog. // TODO: Selenium: test Skill dropdown for Chambita/specialized skill, test total changes }
public ActionResult DeleteConfirmed(int id) { WorkAssignment workAssignment = db.WorkAssignments.Find(id); db.WorkAssignments.Remove(workAssignment); db.SaveChanges(); return(RedirectToAction("Index")); }
async void Lopetus_Nappi_Clicked(object sender, EventArgs e) { WorkAssignment wa = (WorkAssignment)workList.SelectedItem; if (wa == null) { await DisplayAlert("Valinta puuttuu", "Valitse työtehtävä", "OK"); return; } string result = await DisplayPromptAsync("Kommentti", "Kirjoita kommentti"); try { Operation op = new Operation { EmployeeID = eId, WorkAssidnmentID = wa.IdWorkAssingment, CustomerID = wa.IdCustomer, OperationType = "stop", Comment = result, Latitude = lat, Longitude = lon }; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://timesheetbackend.azurewebsites.net/"); // Muutetaan em. op objekti Jsoniksi string input = JsonConvert.SerializeObject(op); StringContent content = new StringContent(input, Encoding.UTF8, "application/json"); // Lähetetään serialisoitu objekti back-endiin Post pyyntönä HttpResponseMessage message = await client.PostAsync("/api/workassignments", content); // Otetaan vastaan palvelimen vastaus string reply = await message.Content.ReadAsStringAsync(); // Asetetaan vastaus serialisoituna success muuttujaan bool success = JsonConvert.DeserializeObject <bool>(reply); if (success == false) { await DisplayAlert("Ei voida lopettaa", "Työtä ole aloitettu", "OK"); } else if (success == true) { await DisplayAlert("Työn päättyminen", "Työ on päättynyt", "OK"); await Navigation.PushAsync(new WorkAssignmentPage(eId)); } } catch (Exception ex) { await DisplayAlert("Virhe: ", ex.Message.ToString(), "SELVÄ"); } }
public SimulatedAnnealing() { Problem = new WorkAssignment(); // get the startpoint. this.Current = this.Problem.Solutions[rnd.Next(this.Problem.Solutions.Count())]; this.Examinee = new List <int>(); this.OptimalSolution = this.Current; }
private List <Person> InitializePopulation() { WorkAssignment wa = new WorkAssignment(); wa.LoadFromFile("wa_nsgaii_input.txt"); //wa.GeneratePeople(50); return(wa.People); }
public NSGA() { stopwatch = new Stopwatch(); workAssignment = new WorkAssignment(); workAssignment.LoadFromFile("Salary.txt"); People = workAssignment.People; }
async void Aloitus_Nappi_Clicked(object sender, EventArgs e) { WorkAssignment wa = (WorkAssignment)workList.SelectedItem; if (wa == null) { await DisplayAlert("Valinta puuttuu", "Valitse työtehtävä.", "OK"); } try { Operation op = new Operation { EmployeeID = eId, WorkAssignmentID = wa.IdWorkAssignment, CustomerID = wa.IdCustomer, OperationType = "start", Comment = "Aloitettu" }; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://timesheetbackend2021.azurewebsites.net/"); // Muutetaan em. data objekti Jsoniksi string input = JsonConvert.SerializeObject(op); StringContent content = new StringContent(input, Encoding.UTF8, "application/json"); // Lähetetään serialisoitu objekti back-endiin Post pyyntönä HttpResponseMessage message = await client.PostAsync("/api/workassignments", content); // Otetaan vastaan palvelimen vastaus string reply = await message.Content.ReadAsStringAsync(); //Asetetaan vastaus serialisoituna success muuttujaan bool success = JsonConvert.DeserializeObject <bool>(reply); if (success == false) { await DisplayAlert("Ei voida aloittaa", "Työ on jo käynnissä", "OK"); } else if (success == true) { await DisplayAlert("Työ aloitettu", "Työ on aloitettu", "OK"); } } catch (Exception ex) { await DisplayAlert(ex.GetType().Name, ex.Message, "OK"); } }
public ActionResult Edit([Bind(Include = "id_WorkAssignment,id_Customer,Title,Description,Deadline,InProsess,InProgressAt,Completed,CompletedAt,CreatedAt,LastModifiedAt,DeletedAt,Active")] WorkAssignment workAssignment) { if (ModelState.IsValid) { db.Entry(workAssignment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_Customer = new SelectList(db.Customers, "id_Customer", "CustomerName", workAssignment.id_Customer); return(View(workAssignment)); }
public FluentRecordBase AddWorkAssignment( string desc = null, int?skill = null, DateTime?datecreated = null, DateTime?dateupdated = null, string updatedby = null, bool assignWorker = false ) { // // DEPENDENCIES if (_wo == null) { AddWorkOrder(); } if (assignWorker == true && _w == null) { AddWorker(); } _servWA = container.Resolve <IWorkAssignmentService>(); // // ARRANGE _wa = (WorkAssignment)Records.assignment.Clone(); _wa.workOrder = _wo; if (assignWorker) { _wa.workerAssigned = _w; } if (datecreated != null) { _wa.datecreated = (DateTime)datecreated; } if (dateupdated != null) { _wa.dateupdated = (DateTime)dateupdated; } if (desc != null) { _wa.description = desc; } if (updatedby != null) { _user = updatedby; } if (skill != null) { _wa.skillID = (int)skill; } // // ACT _servWA.Create(_wa, _user); return(this); }
// GET: WorkAssignmentsPage/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WorkAssignment workAssignment = db.WorkAssignments.Find(id); if (workAssignment == null) { return(HttpNotFound()); } return(View(workAssignment)); }
public static Event ToEvent(this WorkAssignment workAssignment) { return(new Event { Summary = workAssignment.Placement, Start = new EventDateTime { DateTime = workAssignment.Start.DateTime, TimeZone = "Europe/Amsterdam" }, End = new EventDateTime { DateTime = workAssignment.End.DateTime, TimeZone = "Europe/Amsterdam" }, Description = workAssignment.EventDescription() }); }
// GET: WorkAssignmentsPage/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WorkAssignment workAssignment = db.WorkAssignments.Find(id); if (workAssignment == null) { return(HttpNotFound()); } ViewBag.id_Customer = new SelectList(db.Customers, "id_Customer", "CustomerName", workAssignment.id_Customer); return(View(workAssignment)); }
public void GetWorkAssignment_returns_workAssignment() { // //Arrange WorkAssignment assignment = (WorkAssignment)Records.assignment.Clone(); assignment.ID = 1; //This matches Records._workAssignment3 ID value waRepo.Setup(r => r.GetById(1)).Returns(assignment); //Act var result = waServ.Get(1); //Assert Assert.IsInstanceOfType(result, typeof(WorkAssignment)); Assert.IsTrue(result.ID == 1); }
public void TestInitialize() { _savedWorkAssignment = new WorkAssignment(); _fakeWorkAssignment = new WorkAssignment() { active = true, ID = 1, hourRange = 9, hours = 5, weightLifted = true, hourlyWage = 65, description = "asdfasdf" }; _fakeWorkAssignments = new List <WorkAssignment>(); _fakeWorkAssignments.Add(new WorkAssignment() { active = true, ID = 2, hourRange = 8, hours = 3, weightLifted = false, hourlyWage = 10, description = "rghj" }); _waServ = new Mock <IWorkAssignmentService>(); _waServ.Setup(s => s.GetAll()) .Returns(_fakeWorkAssignments.AsQueryable); _waServ.Setup(s => s.Get(1)) .Returns(_fakeWorkAssignment); _waServ.Setup(s => s.Get(1000)) .Returns((WorkAssignment)null); _waServ.Setup(s => s.Create(It.IsAny <WorkAssignment>(), It.IsAny <string>())) .Returns(_fakeWorkAssignment); _waServ.Setup(s => s.Save(It.Is <WorkAssignment>(r => r.ID == 1), It.IsAny <string>())) .Callback((WorkAssignment wa, string user) => _savedWorkAssignment = wa); _waServ.Setup(s => s.Delete(1, It.IsAny <string>())) .Verifiable(); var mapperConfig = new MapperConfiguration(config => { config.ConfigureApi(); }); _mapper = mapperConfig.CreateMapper(); _controller = new WorkAssignmentsController(_waServ.Object, _mapper); }
/// <summary> /// Activate work order. Assumes start at WA ListTab. /// </summary> /// <param name="_emp"></param> /// <param name="_wo"></param> /// <param name="_wa"></param> /// <returns></returns> public bool workAssignmentActivate(Employer _emp, WorkOrder _wo, WorkAssignment _wa) { // Verify we're on the WA ListTab we expected WaitForElement(By.Id("walt-" + _wo.ID)); // Look for WA datatable to have a first row (at least one record) By walt = By.XPath("//table[@id='workAssignTable-wo-" + _wo.ID + "']/tbody/tr/td[1]"); // The #####-## order number from the first column var waltText = "Assignment #: " + WaitForElement(walt).Text; WaitForElementValue(walt, _wa.tablabel); Assert.AreEqual(_wa.tablabel, waltText, "Unexpected PseudoID in assignment's list"); Thread.Sleep(1000); WaitThenClickElement(By.Id("activateWorkOrderButton-" + _wo.ID)); // todo: find a way to change this hard-coded value assignment _wo.statusID = 40; // changing test object to reflect activate status from previous action return(true); }
public void DeleteWorkAssignment() { // //Arrange string user = "******"; int id = 1; var _wa = (WorkAssignment)Records.assignment.Clone(); WorkAssignment dp = new WorkAssignment(); waRepo.Setup(r => r.Delete(It.IsAny <WorkAssignment>())).Callback((WorkAssignment p) => { dp = p; }); waRepo.Setup(r => r.GetById(id)).Returns(_wa); // //Act waServ.Delete(id, user); // //Assert Assert.AreEqual(dp, _wa); }
/// <summary> /// Create new assignment. Last action executes Create Button, returning to List Tab. /// </summary> /// <param name="emp"></param> /// <param name="wo"></param> /// <param name="wa"></param> /// <returns></returns> public bool workAssignmentCreate(Employer emp, WorkOrder wo, WorkAssignment wa) { // Click on the assignment Create Tab WaitThenClickElement(By.Id("wact-" + wo.ID)); //the ID here is the WorkOrder.ID, not the Employer.ID WaitForElement(By.Id(wa.idPrefix + "description")); SelectOption(By.Id(wa.idPrefix + "englishLevelID"), wa.englishLevelID.ToString()); SelectOptionByValue(By.Id(wa.idPrefix + "skillID"), wa.skillID.ToString()); ReplaceElementText(By.Id(wa.idPrefix + "hourlyWage"), wa.hourlyWage.ToString()); ReplaceElementText(By.Id(wa.idPrefix + "hours"), wa.hours.ToString()); if (wa.hourRange.ToString().Length > 0) { SelectOption(By.Id(wa.idPrefix + "hourRange"), wa.hourRange.ToString()); } SelectOption(By.Id(wa.idPrefix + "days"), wa.days.ToString()); ReplaceElementText(By.Id(wa.idPrefix + "description"), wa.description); WaitForElement(By.Id("WO" + wo.ID + "-waCreateBtn")).Click(); Thread.Sleep(1000); wa.ID = getSelectedTabRecordID("WA"); WaitForElement(By.Id(wa.idPrefix + "EditTab")); WaitThenClickElement(By.Id("walt-" + wo.ID)); return(true); }
public bool PostStatus(WorkAssignmentOperationModel input) { MobileDBEntities1 entities = new MobileDBEntities1(); try { WorkAssignment assignment = (from e in entities.WorkAssignments where (e.Active == true) && (e.Title == input.AssignmentTitle) select e).FirstOrDefault(); if (assignment == null) { return(false); } if (input.Operation == "Start") { int assignmentId = assignment.Id_WorkAssignment; Timesheet newEntry = new Timesheet() { Id_WorkAssignment = assignmentId, StartTime = DateTime.Now, WorkComplete = false, Active = true, CreatedAt = DateTime.Now }; entities.Timesheets.Add(newEntry); //assignment.InProgress = true; //assignment.InProgressAt = DateTime.Now; //assignment.LastModifiedAt = DateTime.Now; } else if (input.Operation == "Stop") { int assignmentId = assignment.Id_WorkAssignment; Timesheet existing = (from op in entities.Timesheets where (op.Id_WorkAssignment == assignmentId) && (op.Active == true) && (op.WorkComplete == false) orderby op.StartTime descending select op).FirstOrDefault(); if (existing != null) { existing.StopTime = DateTime.Now; existing.WorkComplete = true; existing.LastModifiedAt = DateTime.Now; //assignment.InProgress = false; //assignment.Completed = true; //assignment.CompletedAt = DateTime.Now; //assignment.LastModifiedAt = DateTime.Now; } else { return(false); } } entities.SaveChanges(); } catch { return(false); } finally { entities.Dispose(); } return(true); }
public bool PostWork(WorkModel model) { WorksheetEntities entities = new WorksheetEntities(); Customer customer = (from cu in entities.Customers where (cu.Active == true) && (cu.CustomerName == model.CustomerName) select cu).FirstOrDefault(); try { // Save chosen work if (model.Operation == "Save") { WorkAssignment newEntry = new WorkAssignment() { Id_Customer = customer.Id_Customer, Title = model.WorkTitle, Description = model.Description, Deadline = model.Deadline, InProgress = true, CreatedAt = DateTime.Now, Active = true }; entities.WorkAssignments.Add(newEntry); } // Modify chosen work else if (model.Operation == "Modify") { WorkAssignment existing = (from wa in entities.WorkAssignments where (wa.Id_WorkAssignment == model.WorkID) && (wa.Active == true) select wa).FirstOrDefault(); if (existing != null) { existing.Title = model.WorkTitle; existing.Description = model.Description; existing.Deadline = model.Deadline; existing.LastModifiedAt = DateTime.Now; } else { return(false); } } // Delete chosen work else if (model.Operation == "Delete") { WorkAssignment existing = (from wa in entities.WorkAssignments where (wa.Id_WorkAssignment == model.WorkID) select wa).FirstOrDefault(); if (existing != null) { entities.WorkAssignments.Remove(existing); } else { return(false); } } // Assign chosen work to an employee else if (model.Operation == "Assign") { WorkAssignment assignment = (from wa in entities.WorkAssignments where (wa.Id_WorkAssignment == model.WorkID) && (wa.Active == true) && (wa.InProgress == true) select wa).FirstOrDefault(); if (assignment == null) { return(false); } Employee emp = (from e in entities.Employees where (e.Id_Employee == model.EmployeeId) select e).FirstOrDefault(); if (emp == null) { return(false); } int workId = assignment.Id_WorkAssignment; int customerId = assignment.Id_Customer.Value; assignment.InProgressAt = DateTime.Now; Timesheet newEntry = new Timesheet() { Id_Customer = customerId, Id_Contractor = emp.Id_Contractor, Id_Employee = emp.Id_Employee, Id_WorkAssignment = workId, StartTime = DateTime.Now, CreatedAt = DateTime.Now, Active = true, WorkComplete = false }; entities.Timesheets.Add(newEntry); } else if (model.Operation == "MarkComplete") { WorkAssignment assignment = (from wa in entities.WorkAssignments where (wa.Id_WorkAssignment == model.WorkID) && (wa.Active == true) && (wa.InProgress == true) && (wa.InProgressAt != null) select wa).FirstOrDefault(); if (assignment == null) { return(false); } int workId = assignment.Id_WorkAssignment; int customerId = assignment.Id_Customer.Value; assignment.CompletedAt = DateTime.Now; assignment.Completed = true; assignment.InProgress = false; Timesheet existing = (from e in entities.Timesheets where (e.Id_WorkAssignment == workId) && (e.Id_Customer == customerId) select e).FirstOrDefault(); if (existing != null) { existing.WorkComplete = true; existing.StopTime = DateTime.Now; existing.LastModifiedAt = DateTime.Now; existing.Comments = "Work set to complete by Admin"; } } entities.SaveChanges(); } catch { return(false); } finally { entities.Dispose(); } return(true); }
public bool PostStatus(WorkAssignmentOperationModel input) { TimesheetEntities entities = new TimesheetEntities(); try { WorkAssignment assignment = (from wa in entities.WorkAssignments where (wa.Active == true) && (wa.Title == input.AssignmentTitle) select wa).FirstOrDefault(); if (assignment == null) { return(false); } //string value; //decimal number; NumberStyles style; CultureInfo provider; provider = new CultureInfo("fi-FI"); string valueString = input.Latitude.ToString("R", CultureInfo.InvariantCulture); style = NumberStyles.AllowDecimalPoint; if (input.Operation == "Start") { int assignmentId = assignment.id_WorkAssignment; Timesheet newEntry = new Timesheet() { id_WorkAssignment = assignmentId, StartTime = DateTime.Now, WorkComplete = false, Active = true, CreatedAt = DateTime.Now, Latitude = Convert.ToDecimal(input.Latitude), Longitude = Convert.ToDecimal(input.Longitude) }; entities.Timesheets.Add(newEntry); } else if (input.Operation == "Stop") { int assignmentId = assignment.id_WorkAssignment; Timesheet existing = (from ts in entities.Timesheets where (ts.id_WorkAssignment == assignmentId) && (ts.Active == true) && (ts.WorkComplete == false) orderby ts.StartTime descending select ts).FirstOrDefault(); if (existing != null) { existing.StopTime = DateTime.Now; existing.WorkComplete = true; existing.LastModifiedAt = DateTime.Now; } else { return(false); } } entities.SaveChanges(); } catch { return(false); } finally { entities.Dispose(); } return(true); }
public static string EventDescription(this WorkAssignment workAssignment) => EventDescriptionPrefix + workAssignment.Id;
public bool PostStatus(WorkAssignmentOperationModel input) { TimesheetEntities entities = new TimesheetEntities(); try { WorkAssignment assignment = (from wa in entities.WorkAssignments where (wa.Active == true) && (wa.Title == input.AssignmentTitle) select wa).FirstOrDefault(); if (assignment == null) { return(false); } if (input.Operation == "Start") { int assignmentId = assignment.Id_WorkAssignment; Timesheet newEntry = new Timesheet() { Id_WorkAssignment = assignmentId, StartTime = DateTime.Now, WorkComplete = false, Active = true, CreatedAt = DateTime.Now }; entities.Timesheets.Add(newEntry); } else if (input.Operation == "Stop") { int assignmentId = assignment.Id_WorkAssignment; Timesheet existing = (from ts in entities.Timesheets where (ts.Id_WorkAssignment == assignmentId) && (ts.Active == true) && (ts.WorkComplete == false) orderby ts.StartTime descending select ts).FirstOrDefault(); if (existing != null) { existing.StopTime = DateTime.Now; existing.WorkComplete = true; existing.LastModifiedAt = DateTime.Now; } else { return(false); } } entities.SaveChanges(); } catch { return(false); } finally { entities.Dispose(); } return(true); }
public bool StartStop(Operation op) { if (op == null) { return(false); } WorkAssignment assignment = (from w in db.WorkAssignments where (w.Active == true) && (w.IdWorkAssignment == op.WorkAssignmentID) select w).FirstOrDefault(); if (assignment == null) { return(false); } // Start else if (op.OperationType == "start") { if (assignment.InProgress == true || assignment.Completed == true) { return(false); } assignment.InProgress = true; assignment.WorkStartedAt = DateTime.Now.AddHours(2); assignment.LastModifiedAt = DateTime.Now.AddHours(2); db.SaveChanges(); Timesheet newEntry = new Timesheet() { IdWorkAssignment = op.WorkAssignmentID, StartTime = DateTime.Now.AddHours(2), Active = true, IdEmployee = op.EmployeeID, IdCustomer = op.CustomerID, CreatedAt = DateTime.Now.AddHours(2), Comments = op.Comment }; db.Timesheets.Add(newEntry); db.SaveChanges(); //<-------------- Tämä puuttui, ja siksi ei luonutkaan uutta timesheetiä. Ongelma ilmeni salakavalasti vasta STOP vaiheessa return(true); } // Stop else { if (assignment.InProgress == false || assignment.Completed == true) { return(false); } assignment.InProgress = false; assignment.CompletedAt = DateTime.Now.AddHours(2); assignment.Completed = true; assignment.LastModifiedAt = DateTime.Now.AddHours(2); db.SaveChanges(); Timesheet ts = (from t in db.Timesheets where (t.Active == true) && (t.IdWorkAssignment == op.WorkAssignmentID) select t).FirstOrDefault(); ts.StopTime = DateTime.Now.AddHours(2); ts.LastModifiedAt = DateTime.Now.AddHours(2); ts.Comments = op.Comment; db.SaveChanges(); return(true); } }
public static string ToLogInfo(this WorkAssignment workAssignment) => $"({workAssignment.Id}) [{workAssignment.Start.DateTime:d}] {workAssignment.Start.DateTime:t} -> {workAssignment.End.DateTime:t} - {workAssignment.Placement}";
public bool workAssignmentValidate(Employer _emp, WorkOrder _wo, WorkAssignment _wa) { Thread.Sleep(1000); WaitThenClickElement(By.Id("WO" + _wo.ID + "-EditTab")); Thread.Sleep(1000); WaitThenClickElement(By.Id("WO" + _wo.ID + "-EditTab")); Thread.Sleep(1000); WaitForElement(By.Id("walt-" + _wo.ID)); WaitThenClickElement(By.Id("walt-" + _wo.ID)); Thread.Sleep(1000); WaitForElement(By.Id("workAssignTable-wo-" + _wo.ID + "_searchbox")); string idString = _wo.ID.ToString("D5") + "-" + ((int)_wa.pseudoID).ToString("D2"); ReplaceElementText(By.Id("workAssignTable-wo-" + _wo.ID + "_searchbox"), idString); Thread.Sleep(1000); string xpath = "//*[@id='workAssignTable-wo-" + _wo.ID + "']/tbody/tr/td[.='" + idString + "']"; Assert.IsTrue(WaitAndDoubleClick(By.XPath(xpath)), "Cannot find work assignment row to click."); //Now, check each of the fields string prefix = "WA" + _wa.ID + "-"; WaitForElement(By.Id(prefix + "englishLevelID")); WaitForElement(By.Id(prefix + "hours")); //Doing a lot of waits up front here because I was having some problems with the englishLevelID getting WaitForElement(By.Id(prefix + "hourRange")); //detached from the DOM if I grab it too early. A short sleep seemed to work, but waits make sure. WaitForElement(By.Id(prefix + "days")); WaitForElement(By.Id(prefix + "skillID")); WaitForElement(By.Id(prefix + "hourlyWage")); WaitForElement(By.Id(prefix + "total")); Thread.Sleep(50); Assert.AreEqual(_wa.englishLevelID.ToString(), GetOptionValue(By.Id(prefix + "englishLevelID"))); Assert.AreEqual(System.String.Format("{0,2:N2}", _wa.hours), WaitForElement(By.Id(prefix + "hours")).GetAttribute("value")); if (_wa.hourRange != null) { Assert.AreEqual(_wa.hourRange, GetOptionIndex(By.Id(prefix + "hourRange")) + 6); } Assert.AreEqual(_wa.days, GetOptionIndex(By.Id(prefix + "days"))); string skillIDValue = GetOptionValue(By.Id(prefix + "skillID")); Assert.AreEqual(_wa.skillID.ToString(), skillIDValue); WaitForElement(By.Id(prefix + "hourlyWage")); Assert.AreEqual(_wa.hourlyWage.ToString("F"), WaitForElement(By.Id(prefix + "hourlyWage")).GetAttribute("value")); WaitForElement(By.Id(prefix + "total")); Assert.AreEqual("$" + (_wa.hourlyWage * _wa.hours * _wa.days).ToString("F"), WaitForElement(By.Id(prefix + "total")).GetAttribute("value")); Assert.AreEqual(_wa.pseudoID.ToString(), WaitForElement(By.Id(prefix + "pseudoID")).GetAttribute("Value")); // Now change field values and check field relationships //reset to default values SelectOptionByIndex(By.Id(prefix + "englishLevelID"), 0); SelectOptionByIndex(By.Id(prefix + "skillID"), 0); ReplaceElementText(By.Id(prefix + "hourlyWage"), "0"); ReplaceElementText(By.Id(prefix + "hours"), "0"); SelectOptionByIndex(By.Id(prefix + "hourRange"), 0); SelectOptionByIndex(By.Id(prefix + "days"), 0); SelectOptionByIndex(By.Id(prefix + "hourRange"), 0); //check default form response Assert.AreEqual("not calculable", WaitForElement(By.Id(prefix + "total")).GetAttribute("value")); Assert.AreEqual("not calculable", WaitForElement(By.Id(prefix + "totalRange")).GetAttribute("value")); //change skill and make sure wage and hours changed SelectOptionByIndex(By.Id(prefix + "skillID"), 1); Assert.IsFalse(Convert.ToInt32(WaitForElement(By.Id(prefix + "hourlyWage")).GetAttribute("value")) == 0, "Hourly Wage failed reaction to skill selection"); Assert.IsFalse(Convert.ToInt32(WaitForElement(By.Id(prefix + "hours")).GetAttribute("value")) == 0, "Hours failed reaction to skill selection"); //var indexResult = GetOptionIndex(By.Id(prefix + "hours")); //Assert.AreEqual(0, indexResult, "Hours dropdown failed reaction to skill selection"); //set hourly range and days then check total and max total SelectOptionByIndex(By.Id(prefix + "hourRange"), 3); SelectOptionByIndex(By.Id(prefix + "days"), 1); int hourlyWage = Convert.ToInt32(WaitForElement(By.Id(prefix + "hourlyWage")).GetAttribute("value")); int hoursWork = Convert.ToInt32(WaitForElement(By.Id(prefix + "hours")).GetAttribute("value")); int hourRange = Convert.ToInt32(GetOptionValue(By.Id(prefix + "hourRange"))); int daysWork = Convert.ToInt32(GetOptionValue(By.Id(prefix + "days"))); Assert.AreEqual("$" + (hourlyWage * hoursWork * daysWork).ToString("F"), WaitForElement(By.Id(prefix + "total")).GetAttribute("value"), "Total pay doesn't match hour, wage and day calculation"); Assert.AreEqual("$" + (hourlyWage * hourRange * daysWork).ToString("F"), WaitForElement(By.Id(prefix + "totalRange")).GetAttribute("value"), "Max Total pay doesn't match hourRange, wage and day calculation"); //select fixed job and verify hourly pay is fixed // TODO: Find another way of testing this. I took fixed categories out of the Lookups. // Centers should be aware that they *can* fix pay in the config, but Casa Latina is the // only center that's had that as a requirement for certain types of jobs. //String skillValue = MacheteLookup.cache.First(x => x.category == LCategory.skill && x.text_EN == "DWC Chambita 1hr").ID.ToString(); //SelectOptionByValue(By.Id(prefix + "skillID"), skillValue); //Thread.Sleep(1000); // to avoid race condition //Assert.AreEqual("true", WaitForElement(By.Id(prefix + "hourlyWage")).GetAttribute("disabled"), "Hourly Wage should be fixed (disabled) in response to skill selection"); return(true); }
public bool StartStop(Operation op) { if (op == null) { return(false); } WorkAssignment assignment = (from w in db.WorkAssignments where (w.Active == true) && (w.IdWorkAssingment == op.WorkAssidnmentID) select w).FirstOrDefault(); if (assignment == null) { return(false); } // -----------------------------Start------------------------------------------------------------------ else if (op.OperationType == "start") { if (assignment.InProgress == true || assignment.Completed == true) { return(false); } assignment.InProgress = true; assignment.WorkStartedAt = DateTime.Now.AddHours(3); assignment.LastModifiedAt = DateTime.Now.AddHours(3); db.SaveChanges(); Timesheet newEntry = new Timesheet() { IdWorkAssignment = op.WorkAssidnmentID, StartTime = DateTime.Now.AddHours(3), Active = true, IdEmployee = op.EmployeeID, IdCustomer = op.CustomerID, CreatedAt = DateTime.Now.AddHours(3), Comments = op.Comment, Latitude = op.Latitude, Longitude = op.Longitude }; db.Timesheets.Add(newEntry); db.SaveChanges(); return(true); } // -------------------- IF STOP ------------------------------------------------------------------------ else { if (assignment.InProgress == false || assignment.Completed == true) { return(false); } assignment.InProgress = false; assignment.CompletedAt = DateTime.Now.AddHours(3); assignment.Completed = true; assignment.LastModifiedAt = DateTime.Now.AddHours(3); Timesheet ts = (from t in db.Timesheets where (t.Active == true) && (t.IdWorkAssignment == op.WorkAssidnmentID) select t).FirstOrDefault(); ts.StopTime = DateTime.Now.AddHours(3); ts.LastModifiedAt = DateTime.Now.AddHours(3); ts.Comments = op.Comment; ts.Longitude = op.Longitude; ts.Latitude = op.Latitude; db.SaveChanges(); return(true); } }
private async Task UpdateExistingEvent(Google.Apis.Calendar.v3.CalendarService service, WorkAssignment workAssignment, Event existingEvent) { if (EventRequiresUpdating(existingEvent, workAssignment)) { _logger.Info($"Event requires updating to: {workAssignment.ToLogInfo()}"); var updatedEvent = workAssignment.ToEvent(); updatedEvent.Description = existingEvent.Description; await service.Events.Update(updatedEvent, SettingsService.Settings.TargetCalendarId, existingEvent.Id).ExecuteAsync(); } }