public IActionResult EmployeeWorkoutMetrics() { Timelog model = new Timelog(); IList <User> list = userDAL.GetMembers(); model.AllMembers = memberDAL.UsersListForDropdown(list); return(View(model)); }
//Delete Timelog public async Task <Timelog> DeleteTimelog(Timelog TimelogID) { _onlineTimeTrackContext.Timelogs.Remove(TimelogID); await _onlineTimeTrackContext.SaveChangesAsync(); var ExistingTimelog = _onlineTimeTrackContext.Timelogs.FirstOrDefault(x => x.TimelogID == TimelogID.TimelogID); return(ExistingTimelog); }
public IActionResult MemberTimelog() { Timelog model = new Timelog(); User user = authProvider.GetCurrentUser(); if (user.Role.ToLower() == "member") { model.MemberId = user.Id; model.IsCheckedIn = memberDAL.CheckedInStatusButNotCheckedOut(user.Id); } return(View(model)); }
public IActionResult EmployeeTimelog(Timelog model) { if (model.IsCheckedIn) { memberDAL.CheckOut(model.MemberId); } else { memberDAL.CheckIn(model.MemberId); } return(RedirectToAction(nameof(EmployeeTimelog))); }
private void takeSnapshot() { timeoffset += 60; // Add 60 seconds to offset DateTime datetime = new DateTime(1970, 1, 1); datetime = datetime.AddSeconds(timestamp + timeoffset); string time_key = datetime.ToString("HH:mm"); Activity act = new Activity(); act.k = keyPressCount; act.m = mouseClickCount; activities.Add(time_key, act); keyPressCount = 0; mouseClickCount = 0; if (timeoffset >= nextsnaptime) { synctime = timestamp + timeoffset; // Calculate Next time int mins = datetime.Minute; int offset = (((mins / 10) + 1) * 10 + randObj.Next(0, 9)) - mins; nextsnaptime = timeoffset + (UInt64)(offset * 60); screenshot = GetScreenShot(); //Image thumbnail = screenshot.GetThumbnailImage(160, 120, null, new IntPtr()); ScreenPictureBox.Image = screenshot; Snapshot snapshot = new Snapshot(); snapshot.contract = currentContract; snapshot.comment = MemoTextBox.Text; snapshot.active_window = "ActiveWin"; snapshot.activities = activities; activities = new Dictionary <string, Activity>(); Dictionary <string, Snapshot> logs = new Dictionary <string, Snapshot>(); logs.Add(synctime.ToString(), snapshot); timelog = new Timelog(); timelog.token = MainForm.userInfo.token; timelog.logs = logs; //trayIcon.ShowBalloonTip(5, "Screenshot", "Just take screenshot",ToolTipIcon.Info); popup.setScreenshot(screenshot); popup.Show(); popup.StartDiscount(); } }
public async Task <ActionResult <Timelog> > Put(Guid id, [FromBody] Timelog timelog) { try { var result = timelogRepo.Retrieve().FirstOrDefault(x => x.LogID == id); if (result == null) { return(NotFound()); } await timelogRepo.UpdateAsync(id, timelog); return(Ok(timelog)); } catch (Exception) { return(BadRequest()); } }
public async Task <Timelog> Timelog(Timelog timelog) { // save the Timelog var Timelog = await _onlineTimeTrackContext.Timelogs.AddAsync(timelog); timelog.WorklogID = timelog.WorklogID; timelog.ActualWorkTimeStart = timelog.ActualWorkTimeStart; timelog.ActualWorkTimeEnd = timelog.ActualWorkTimeEnd; timelog.DateAdded = DateTime.UtcNow; timelog.DateModified = DateTime.UtcNow; await _onlineTimeTrackContext.SaveChangesAsync(); // return thetimelog return(timelog); }
public async Task <ActionResult <Timelog> > Post([FromBody] Timelog timelog) { try { timelog.LogID = Guid.NewGuid(); await timelogRepo.CreateAsync(timelog); return(CreatedAtRoute("GetDepartmentByID", new { id = timelog.LogID }, timelog)); } catch (Exception) { return(BadRequest()); } }
public async Task <Response <Timelog> > Timelog([FromBody] Timelog timelog) { if (timelog == null) { return(Response <Timelog> .CreateResponse(false, "Please provide valid Timelog Id.", null)); } try { var newTimelog = await _timelogService.Timelog(timelog); return(Response <Timelog> .CreateResponse(true, "Successfully uploaded.", newTimelog)); } catch (Exception e) { return(Response <Timelog> .CreateResponse(false, e.Message, null)); } }
public IEnumerable <Timelog> GetAll() { using (var client = new HttpClient()) { List <Timelog> timelogs = new List <Timelog>(); //Retrieving a JSON-Object var response = ExtranetUsersRepository.getResponseAsString("/api/ApiAlpha.ashx/w/TTI/a/TIMELOG/tickets/list?&listOfFields=ALL&withTechnicalData=true").Result; var json = JObject.Parse(response); var results = json["data"].Children().ToList(); //Serialization foreach (JToken t in results) { Timelog timelog = t.ToObject <Timelog>(); timelogs.Add(timelog); } return(timelogs); } }
public async Task <Response <Timelog> > UpdateTimelog([FromBody] Timelog TimelogID) { if (TimelogID == null) { return(Response <Timelog> .CreateResponse(false, "Please provide valid Timelog Id.", null)); } try { var ExistingTimelog = await _timelogService.UpdateTimelog(TimelogID); if (ExistingTimelog == null) { return(Response <Timelog> .CreateResponse(false, "Not a valid Id", null)); } return(Response <Timelog> .CreateResponse(true, "Successfully updated.", ExistingTimelog)); } catch (Exception e) { return(Response <Timelog> .CreateResponse(false, e.Message, null)); } }
public void Update(Timelog timelog) { throw new NotImplementedException(); }
public static WebRequest timelogRequest(Timelog timelog, Image screenshot, UInt64 timestamp) { /* * MemoryStream stream = new MemoryStream(); * DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Timelog)); * ser.WriteObject(stream, timelog); * stream.Position = 0; * StreamReader sr = new StreamReader(stream); * string jsonParam = sr.ReadToEnd(); * string jwt = JWTEncode.encodeJWTFromJSON(jsonParam); * Console.WriteLine(jwt); */ StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.Append("{ \"token\" : \"" + timelog.token + "\", \"logs\": { "); jsonBuilder.Append("\"" + timelog.logs.First().Key + "\" : { "); jsonBuilder.Append("\"contract\" : \"" + timelog.logs.First().Value.contract + "\", "); jsonBuilder.Append("\"comment\" : \"" + timelog.logs.First().Value.comment + "\", "); jsonBuilder.Append("\"active_window\" : \"" + timelog.logs.First().Value.active_window + "\", "); jsonBuilder.Append("\"activities\" : { "); int count = 1; foreach (KeyValuePair <string, Activity> kvp in timelog.logs.First().Value.activities) { jsonBuilder.Append("\"" + kvp.Key + "\": { \"k\" : " + kvp.Value.k + ", \"m\" : " + kvp.Value.m + "}"); if (timelog.logs.First().Value.activities.Count > count) { jsonBuilder.Append(", "); } count++; } jsonBuilder.Append("} } } }"); string jsonParam = jsonBuilder.ToString(); string jwt = JWTEncode.encodeJWTFromJSON(jsonParam); Console.WriteLine(jwt); string boundary = "-----WawJobTracker"; MemoryStream body = new MemoryStream(); byte[] imageData = Encoding.UTF8.GetBytes(String.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: image/jpeg\r\n\r\n", boundary, "screenshot_" + timestamp.ToString(), "screenshot.jpg")); body.Write(imageData, 0, imageData.Length); screenshot.Save(body, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] endData = Encoding.UTF8.GetBytes(String.Format("\r\n--{0}--\r\n", boundary)); body.Write(endData, 0, endData.Length); WebRequest request = WebRequest.Create("http://www.wawjob.com/api/v1/timelog"); // Set the Method property of the request to POST. request.Method = "POST"; request.Headers.Add("JWT", jwt); // Set the ContentType property of the WebRequest. request.ContentType = @"multipart/form-data; boundary=-----WawJobTracker"; // Set the ContentLength property of the WebRequest. request.ContentLength = body.Length; // Get the request stream. Stream dataStream = request.GetRequestStream(); // Write the data to the request stream. dataStream.Write(body.GetBuffer(), 0, (int)body.Length); // Close the Stream object. dataStream.Close(); return(request); }
public IActionResult Update(string id, [FromBody] Timelog timelog) { return(new NoContentResult()); }
public IActionResult Create([FromBody] Timelog timelog) { return(Ok(timelog)); }
public IActionResult EmployeeWorkoutById(Timelog model) { return(RedirectToAction(nameof(MemberWorkoutMetrics), new { id = model.MemberId })); }