public void Get_work_time_for_doctor_for_date_return_doctors()
        {
            workTimeRepository.GetWorkTimesForDoctor(Guid.Parse("7bb28807-f41e-4bf4-b699-6a478051adba")).Returns(this.GetListOfWorkTimes());
            DateTime date = new DateTime(2020, 12, 05);

            WorkTime workTime = workTimeService.GetWorkTimeForDoctorForDate(Guid.Parse("7bb28807-f41e-4bf4-b699-6a478051adba"), date);

            Assert.True(this.CompareWorkTimesForDoctorForDate(this.GetFirstWorkTime(), workTime, date));
        }
Esempio n. 2
0
        public ActionResult UpdateRecord(WorkTime workTime)
        {
            workTime.EmployeeId = UserContext.CurrentUser.UserId;
            WorkTimeLogic wtLogic    = new WorkTimeLogic();
            bool          isApproved = false;
            var           result     = wtLogic.UpdateWorkTime(workTime, ref isApproved);

            return(Json(new { Result = result, Data = workTime, IsApproved = isApproved }));
        }
Esempio n. 3
0
 public static WorkTimeForPartialUpdateDTO GetWorkTimeForPartialUpdateDto(WorkTime workTime)
 {
     return(new WorkTimeForPartialUpdateDTO()
     {
         WorkStartTime = workTime.WorkStartTime,
         WorkEndTime = workTime.WorkEndTime,
         UserId = workTime.UserId,
         TaskId = workTime.TaskId
     });
 }
Esempio n. 4
0
    public void AddWorkTime(WorkTime newWorkTime)
    {
        workTimes.Add(newWorkTime);
        totalWorkTime = TimeSpan.Parse(totalWorkTime).Add(TimeSpan.Parse(newWorkTime.workTime)).ToString();

        if (parentTask != null)
        {
            parentTask.totalWorkTime = TimeSpan.Parse(parentTask.totalWorkTime).Add(newWorkTime.CalculateWorkTime()).ToString();
        }
    }
Esempio n. 5
0
        public static bool ComparePairs(WorkTime a, WorkTime b)
        {
            int minOfMin = Math.Min(Math.Min(a.FirstTime, a.SecondTime), Math.Min(b.FirstTime, b.SecondTime));

            if (minOfMin == a.FirstTime || minOfMin == b.SecondTime)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "ID,start,end")] WorkTime workTime)
 {
     if (ModelState.IsValid)
     {
         db.Entry(workTime).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(workTime));
 }
        partial void WorkTimeSet_Inserting(WorkTime entity)
        {
            entity.WorkDate = entity.WorkDate.Date;
            var replaceEntity = this.WorkTimeSet.Where(x => x.UserId == entity.UserId && x.WorkDate == entity.WorkDate).FirstOrDefault();

            if (replaceEntity != null)
            {
                replaceEntity.Delete();
            }
        }
 public ActionResult Edit([Bind(Include = "ID,UserID,IssueID,LoggedHours,DateLogged")] WorkTime workTime)
 {
     if (ModelState.IsValid)
     {
         db.Entry(workTime).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(workTime));
 }
            public async Task Enter(StateMachine <Triggers, States> sm, WorkTime workTime, WMonitorAlghorithm alghorithm)
            {
                InProgress = true;
                _cts       = new CancellationTokenSource();
                alghorithm._canCapureMouseKeyboard = true;
                bool faceDetected   = false;
                bool faceRecognized = false;


                while (!faceRecognized || !faceDetected)
                {
                    _workTimeEventService.StartTempChanges();
                    _workTimeEventService.TryStartWatchingScreen();
                    _workTimeEventService.StartRecognitionFailure();

                    Log.Logger.Debug($"Starting {_config.Delay} state 3 delay");

                    try
                    {
                        await Task.Delay(_config.Delay, _cts.Token);
                    }
                    catch (TaskCanceledException)
                    {
                        InProgress = false;
                        return;
                    }

                    (faceDetected, faceRecognized) = await _faceRecognition.RecognizeFace(workTime.User);

                    alghorithm.State3Result((faceDetected, faceRecognized));

                    Log.Logger.Debug(
                        $"State 3 face recognized: {faceRecognized} face detected face recognized: {faceDetected}");

                    if (!faceRecognized || !faceDetected)
                    {
                        _workTimeEventService.DiscardTempChanges();
                        if (!TryAddRecognitionFailure(faceDetected, faceRecognized))
                        {
                            InProgress = false;
                            sm.Next(Triggers.Stop);
                            return;
                        }
                    }
                    else
                    {
                        _workTimeEventService.TryAddWatchingScreen();
                        _workTimeEventService.StopRecognitionFailure();
                        _workTimeEventService.CommitTempChanges();
                    }
                }

                InProgress = false;
                sm.Next(Triggers.FaceRecog);
            }
Esempio n. 10
0
        public void AddWorkTime_NewTimeOverlapsWithAlreadyExistTimeAtStartTime_FalseReturn()
        {
            // arrange
            var worker = new Worker {
                FirstName = "Ivan", SurName = "Ivanov", Id = 1, Email = "*****@*****.**", Telephone = "+375251234567"
            };
            var workers = new List <Worker>();

            workers.AddRange(new Worker[] {
                worker
            });
            var workerManagerMock = new Mock <IWorkerManager>();

            workerManagerMock.Setup(m => m.Get()).Returns(workers);

            var worker1time1 = new WorkTime
            {
                Worker    = worker,
                DateStart = new DateTime(2008, 09, 4, 10, 0, 0, DateTimeKind.Unspecified),
                DateEnd   = new DateTime(2008, 09, 4, 18, 0, 0, DateTimeKind.Unspecified)
            };
            var workTime = new List <WorkTime>();

            workTime.AddRange(new WorkTime[] {
                worker1time1
            });
            var workTimeManagerMock = new Mock <IWorkTimeManager>();

            workTimeManagerMock.Setup(m => m.Get()).Returns(workTime);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.WorkerManager).Returns(workerManagerMock.Object);
            unitOfWorkMock.Setup(m => m.WorkTimeManager).Returns(workTimeManagerMock.Object);


            var curentDate = new DateTime(2008, 09, 3, 12, 0, 0, DateTimeKind.Utc);
            var clockMock  = new Mock <IClock>();

            clockMock.Setup(m => m.CurentUtcDateTime()).Returns(curentDate);

            var workerService = new WorkerService(unitOfWorkMock.Object, clockMock.Object);
            var model         = new WorkTimeDTO
            {
                UserId    = worker.Id,
                StartTime = new DateTime(2008, 09, 4, 9, 0, 0, DateTimeKind.Utc),
                EndTime   = new DateTime(2008, 09, 4, 11, 0, 0, DateTimeKind.Utc)
            };
            // act
            var actual = workerService.AddWorkTime(model);

            // assert
            actual.Should().NotBeNull();
            actual.Succedeed.Should().BeFalse();
        }
Esempio n. 11
0
        public void Add(WorkTime model, string email)
        {
            Employee employee = _context.Employee.FirstOrDefault(e => e.Id == model.EmployeeId && e.Owner == email);

            if (employee == null)
            {
                throw new Exception("Decline!!");
            }
            _context.Add(model);
            _context.SaveChanges();
        }
Esempio n. 12
0
 private void Form1_Load(object sender, EventArgs e)
 {
     StartTimeHours          = 10;
     StartTimeMinutes        = 0;
     FinishTimeHours         = 24;
     FinishTimeMinutes       = 0;
     WorkTime                = 14 * 60;
     textBoxTimeDisplay.Text = WorkTime.ToString();
     CurrentMovie            = new Movie();
     AllMovies               = new List <Movie>();
 }
Esempio n. 13
0
 public WorkTime CorrectWorkTime(WorkTime workTime, DateTime newDateTime)
 {
     workTime.WorkDateTime = newDateTime;
     workTime.LastModified = DateTime.Now;
     _context.Worktimes.Update(workTime);
     if (!Save())
     {
         throw new Exception($"Problem while persisting change to work time with id {workTime.WorkTimeID} to database.");
     }
     return(workTime);
 }
Esempio n. 14
0
 public ActionResult Edit([Bind(Include = "Id,StartTime")] WorkTime workTime)
 {
     workTime = db.WorkTimeSet.Find(workTime.Id);
     if (workTime != null)
     {
         db.Entry(workTime).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(workTime));
 }
 public WorkTime AddUpdate(WorkTime obj)
 {
     if (obj.ObjId.ToString() == "0")
     {
         return(Add(obj));
     }
     else
     {
         return(Update(obj));
     }
 }
Esempio n. 16
0
 public void AddTimeEntry(WorkTime workTime)
 {
     using (var db = new DataContext())
     {
         var issue = db.Issues.Where(i => i.IssueID == workTime.IssueID).Single();
         workTime.Issue = issue;
         workTime.Dirty = true;
         db.WorkTimes.Add(workTime);
         db.SaveChanges();
     }
 }
Esempio n. 17
0
        public ActionResult Create([Bind(Include = "ID,start,end")] WorkTime workTime)
        {
            if (ModelState.IsValid)
            {
                db.WorkTimes.Add(workTime);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(workTime));
        }
Esempio n. 18
0
 private void textBoxFinishTime_TextChanged(object sender, EventArgs e)
 {
     if (textBoxFinishTime.Text.Length > 0)
     {
         double FinishTime = Convert.ToDouble(textBoxFinishTime.Text);
         FinishTimeHours         = (int)Math.Floor(FinishTime);
         FinishTimeMinutes       = (int)(FinishTime - FinishTimeHours);
         WorkTime                = (FinishTimeHours - StartTimeHours) * 60 + (FinishTimeMinutes - StartTimeMinutes);
         textBoxTimeDisplay.Text = WorkTime.ToString();
     }
 }
    private void LoadRoleCode40()
    {
        var isSuccess = false;
        var msg       = "";
        var datas     = new List <FlowOrganListMobel>();
        var viewData  = new WorkTimeViewModel()
        {
            UserComp = UserInfo.getUserInfo().CompID,
            UserID   = UserInfo.getUserInfo().UserID,
            CompID   = ddlCompID.SelectedValue,
            FlowType = "D"
        };

        isSuccess = WorkTime.LoadFlowOrgan(viewData, out datas, out msg);
        if (isSuccess && datas != null && datas.Count > 0)
        {
            _AllowFlowOrgan = datas;

            viewData = new WorkTimeViewModel()
            {
                UserComp = UserInfo.getUserInfo().CompID,
                UserID   = UserInfo.getUserInfo().UserID,
                CompID   = ddlCompID.SelectedValue,
                FlowType = "B"
            };

            isSuccess = WorkTime.LoadFlowOrgan(viewData, out datas, out msg);
            if (isSuccess && datas != null && datas.Count > 0)
            {
                _AllowFlowOrganView          = datas;
                ddlRoleCode40.DataSource     = datas.Where(x => x.RoleCode == "40").Select(x => new { x.OrganID, x.OrganName }).Distinct().ToList();
                ddlRoleCode40.DataTextField  = "OrganName";
                ddlRoleCode40.DataValueField = "OrganID";
                ddlRoleCode40.DataBind();
                ddlRoleCode40.Items.Insert(0, new ListItem("---請選擇---", ""));
            }
            else
            {
                _AllowFlowOrganView = new List <FlowOrganListMobel>();
                resetDDL(ddlRoleCode40);
                resetDDL(ddlRoleCode30);
                resetDDL(ddlRoleCode20);
                resetDDL(ddlRoleCode10);
            }
        }
        else
        {
            _AllowFlowOrgan = new List <FlowOrganListMobel>();
            resetDDL(ddlRoleCode40);
            resetDDL(ddlRoleCode30);
            resetDDL(ddlRoleCode20);
            resetDDL(ddlRoleCode10);
        }
    }
        public async Task <IActionResult> AddWorkTime([FromBody] WorkTime workTime)
        {
            var employee = await _employeeService.GetEmployee(workTime.EmployeeId);

            workTime.HourlyWage = employee.HourlyWage;
            workTime.ActualWage = employee.HourlyWage;

            var newEmployeeNewId = await _workTimeService.AddEmployeeWorkTime(workTime);

            return(Json(newEmployeeNewId));
        }
Esempio n. 21
0
 public static WorkTimeDTO GetWorkTimeDto(WorkTime workTime)
 {
     return(new WorkTimeDTO()
     {
         Id = workTime.Id,
         WorkStartTime = workTime.WorkStartTime,
         WorkEndTime = workTime.WorkEndTime,
         UserId = workTime.UserId,
         TaskId = workTime.TaskId
     });
 }
Esempio n. 22
0
        public ActionResult Create([Bind(Include = "Id,ClockIn,ClockOut,WorkDate,EmployeeID")] WorkTime workTime)
        {
            if (ModelState.IsValid)
            {
                ValidateModel(workTime);
                db.WorkTimes.Add(workTime);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(workTime));
        }
Esempio n. 23
0
 public ActionResult Create([Bind(Include = "ID,UserId,IssueId,Time,CreatedAt")] WorkTime workTime)
 {
     workTime.UserId = this.User.Identity.GetUserId();
     if (ModelState.IsValid)
     {
         db.WorkTimes.Add(workTime);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IssueId = new SelectList(db.Issues, "Id", "Title", workTime.IssueId);
     return(View(workTime));
 }
Esempio n. 24
0
        public async Task PostTimeEntryAsync(WorkTime wt)
        {
            Post_Time_Entry pt = new Post_Time_Entry();

            pt.time_entry             = new Time_Entry();
            pt.time_entry.issue_id    = wt.IssueID;
            pt.time_entry.hours       = (float)wt.Hours;
            pt.time_entry.comments    = wt.Comment;
            pt.time_entry.activity_id = 1;

            await networkService.PostTimeEntry(pt);
        }
        private WorkTimeViewModel MapToViewMode(WorkTime workTime)
        {
            WorkTimeViewModel workTimeViewModel = new WorkTimeViewModel();
            var strTime = workTime.StartTime.ToString().PadLeft(4, '0');
            var endTime = workTime.EndTime.ToString().PadLeft(4, '0');

            workTimeViewModel.From        = $"{strTime.Substring(0, 2)}:{strTime.Substring(2, 2)}";
            workTimeViewModel.To          = $"{endTime.Substring(0, 2)}:{endTime.Substring(2, 2)}";
            workTimeViewModel.AvaiableFor = workTime.MealType.ToString();

            return(workTimeViewModel);
        }
Esempio n. 26
0
 public HttpResponseMessage GetWork(int work)
 {
     if (work == 0)
     {
         WorkTime workTime = new WorkTime();
         workTime.start = workTimeString[0];
         workTime.stop  = workTimeString[1];
         workTime.delay = workTimeString[2];
         return(Request.CreateResponse(HttpStatusCode.Created, workTime));
     }
     return(Request.CreateResponse(HttpStatusCode.BadRequest));
 }
Esempio n. 27
0
 public void StopWorking()
 {
     UnityEditor.EditorApplication.quitting -= OnUnityClose;
     if (workTime != null)
     {
         UpdateTimer();
         workTime.StopWork();
         task.AddWorkTime(workTime);
         working  = false;
         workTime = null;
     }
 }
Esempio n. 28
0
        private void ValidateModel(WorkTime workTime)
        {
            if (workTime.ClockIn.HasValue)
            {
                workTime.ClockIn = new DateTime(workTime.WorkDate.Year, workTime.WorkDate.Month, workTime.WorkDate.Day, workTime.ClockIn.Value.Hour, workTime.ClockIn.Value.Second, 0);
            }

            if (workTime.ClockOut.HasValue)
            {
                workTime.ClockOut = new DateTime(workTime.WorkDate.Year, workTime.WorkDate.Month, workTime.WorkDate.Day, workTime.ClockOut.Value.Hour, workTime.ClockOut.Value.Second, 0);
            }
        }
Esempio n. 29
0
        public ActionResult Clock()
        {
            Employee e = s.GetUserData();

            if (e == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            WorkTime today = GetTodayWorkTime();

            return(View(today));
        }
Esempio n. 30
0
        public ActionResult Edit([Bind(Include = "Id,ClockIn,ClockOut,WorkDate,EmployeeID")] WorkTime workTime)
        {
            if (ModelState.IsValid)
            {
                ValidateModel(workTime);
                db.Entry(workTime).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Users = new SelectList(db.Users.ToList(), "Id", "UserName");
            return(View(workTime));
        }
Esempio n. 31
0
 /// <summary>
 /// 作者:Raymond
 /// 时间:2013-12-10
 /// 描述:更新班次缓存
 /// </summary>
 /// <param name="workTime"></param>
 public static void UpdateWorkTimeCache(WorkTime workTime)
 {
     if (workTime != null)
     {
         Icache.Set(string.Format("{0}{1}", Kword, workTime.Id), workTime, 180 * 24 * 60);
     }
 }
Esempio n. 32
0
 /// <summary>
 /// 作者:Raymond
 /// 时间:2013-12-10
 /// 描述:设置班次缓存
 /// </summary>
 /// <param name="workTime"></param>
 public static void SetWorkTimeCache(WorkTime workTime)
 {
     if (null == workTime) return;
     if (!Icache.IsSet(string.Format("{0}{1}", Kword, workTime.Id)))
     {
         Icache.Set(string.Format("{0}{1}", Kword, workTime.Id), workTime, 180 * 24 * 60);
     }
 }
Esempio n. 33
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.01.20
        /// 描述:创建班次信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="details"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static WorkTime CreateWorkTime(WorkTime model, List<WorkTimeDetail> details, int loginUserId)
        {
            using (var tran = new TransactionScope())
            {
                using (var edb = new EmeEntities())
                {
                    try
                    {
                        edb.Entry(model).State = EntityState.Added;
                        edb.SaveChanges();
                        foreach (var detail in details)
                        {
                            detail.WorkTimeId = model.Id;
                            edb.Entry(detail).State = EntityState.Added;
                        }

                        edb.SaveChanges();
                        tran.Complete();
                        return model;
                    }
                    catch (Exception e)
                    {
                        tran.Dispose();

                        // 异常日志消息队列
                        Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                        {
                            ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                            Message = string.Format("BranchBLL-CreateWorkTime:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                            IsTreat = false,
                            CreateBy = loginUserId,
                            CreateTime = DateTime.Now
                        });
                        return null;
                    }
                }
            }
        }
Esempio n. 34
0
		public void AddWorkTime(WorkTime workTime) {
			this.workTimes.Add(workTime);
			this.SortWorkTimes();
			this.updateFinishedDuration();
		}
Esempio n. 35
0
 /// <summary>
 /// 创建WorkTime节点,属性为WorkTime的中文名
 /// </summary>
 /// <param name="workTime"></param>
 /// <param name="workName"></param>
 /// <returns></returns>
 private static XElement CreateWorkTime(WorkTime workTime, WorkTimeCN workName)
 {
     XElement newWorkTime = new XElement("Root",
             new XElement(workTime.ToString(),
                 new XAttribute("WorkName", workName.ToString()),
             CreateMonths().Elements()
             )
         );
     return newWorkTime;
 }
Esempio n. 36
0
		private void UserControl_Loaded (object sender, RoutedEventArgs e)
			{
			if (System.ComponentModel.DesignerProperties.GetIsInDesignMode (this))
				return;
			WordUpCalendar.DayTabHeader = "Tag";
			WordUpCalendar.WeekTabHeader = "Woche";
			WordUpCalendar.MonthTabHeader = "Monat";
			WordUpCalendar.TimelineTabHeader = "Zeitachse";
			WorkTime WorkStartTime = new WorkTime();
			WorkStartTime.Hour = 8;
			WorkStartTime.Minute = 0;
			WordUpCalendar.OpenAppointment += new DevComponents.WpfSchedule.AppointmentEventHandler (WordUpCalendar_OpenAppointment);
			WordUpCalendar.DateSelectionChanged += new RoutedEventHandler (WordUpCalendar_DateSelectionChanged);
			WordUpCalendar.SelectedViewChanged += new RoutedEventHandler (WordUpCalendar_SelectedViewChanged);
			LoadModel ();
			WordUpCalendar.CalendarModel = ModellData;
			ModellData.AppointmentAdded += new DevComponents.WpfSchedule.Model.AppointmentEventHandler (ModellData_AppointmentAdded);
			ModellData.SubPropertyChanged += new SubPropertyChangedEventHandler (ModellData_SubPropertyChanged);
			}
Esempio n. 37
0
		public void DeleteWorkTime(WorkTime workTime) {
			this.workTimes.Remove(workTime);
			this.updateFinishedDuration();
		}
Esempio n. 38
0
        public ActionResult WorkTimeCreate(FormCollection fc)
        {
            var branchId = Utility.CommonHelper.To<int>(fc["WorkTimeCreateBranchId"]);
            var cName = fc["WorkTimeCreateCName"];
            var eName = fc["WorkTimeCreateEName"];
            var taskNum = Utility.CommonHelper.To<int>(fc["WorkTimeCreateTaskNum"]);
            var timeSpan = fc["WorkTimeCreateTimeSpan"];

            var model = new WorkTime()
            {
                BranchId = branchId,
                CName = cName,
                EName = eName,
                TaskNum = taskNum,
                Status = Utility.CommonHelper.To<int>(StatusType.Active),
                CreateBy = LoginUserManager.CurrLoginUser.UserId,
                CreateTime = DateTime.Now
            };
            var workTimeDetailList = GetTimeDetailListByWorkTimeIdAndTimeSpan(null, timeSpan);
            var worktime = BranchBLL.CreateWorkTime(model, workTimeDetailList, LoginUserManager.CurrLoginUser.UserId);
            var result = (worktime != null);

            if (result)
            {
                WebCommon.Cache.WorkTimeCache.SetWorkTimeCache(worktime);
                WebCommon.Cache.WorkTimeCache.WorkTimeListAddItemByBranchId(branchId, worktime.Id);
            }

            var list = WebCommon.Cache.WorkTimeCache.GetWorkTimeListByBranchId(branchId, null);

            return PartialView("_List", list);
        }