/// <summary>
        /// This method will post the selected timesheet entries for accounting
        /// </summary>
        /// <param name="displayWarnings">if set to <c>true</c> display warnings.</param>
        private void PostTime(bool displayWarnings)
        {
            TimeServiceClient timeService = null;
            EarnerServiceClient earnerService = null;
            try
            {
                UnPostedTimeSearchCriteria searchCriteria = new UnPostedTimeSearchCriteria();
                searchCriteria.UserId = _logonSettings.DbUid;
                searchCriteria.TimeDate = DateTime.Now.Date;

                earnerService = new EarnerServiceClient();
                EarnerReturnValue earnerReturnVal = earnerService.GetFeeEarnerReference(_logonSettings.LogonId,
                                                                                        _logonSettings.MemberId);
                if (earnerReturnVal.Success)
                {
                    searchCriteria.FeeEarnerRef = earnerReturnVal.EarnerRef;
                }
                else
                {
                    throw new Exception(earnerReturnVal.Message);
                }

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = _grdTodaysTimesheet.PageIndex * _grdTodaysTimesheet.PageSize;
                collectionRequest.RowCount = _grdTodaysTimesheet.PageSize;

                //Get unposted time entries
                timeService = new TimeServiceClient();
                UnPostedTimeSearchReturnValue returnValue = timeService.UnPostedTimeSheetSearch(_logonSettings.LogonId,
                                                                                            collectionRequest,
                                                                                            searchCriteria);

                if (returnValue.UnPostedTimeSheet.Rows != null && returnValue.UnPostedTimeSheet.Rows.Length > 0)
                {
                    foreach (GridViewRow row in _grdTodaysTimesheet.Rows)
                    {
                        CheckBox timeSheetSelected = (CheckBox)row.FindControl("_chkSelect");
                        int timeId = (int)_grdTodaysTimesheet.DataKeys[row.RowIndex].Values["TimeId"];

                        //Find the item in the collection
                        UnPostedTimeSearchItem timeSheetItem = returnValue.UnPostedTimeSheet.Rows.First(time => time.TimeId == timeId);

                        //Check if the item is selected
                        if (timeSheetSelected.Checked)
                        {

                            //Validate the posting period
                            PeriodCriteria criteria = new PeriodCriteria();
                            criteria.Date = timeSheetItem.TimeDate;//returnValue.UnPostedTimeSheet.Rows[0].TimeDate;
                            criteria.IsTime = true;
                            criteria.IsPostingVATable = false;
                            criteria.IsAllowedPostBack2ClosedYear = false;

                            PeriodDetailsReturnValue periodDetailsReturnValue = new PeriodDetailsReturnValue();
                            periodDetailsReturnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria);

                            if (periodDetailsReturnValue.Success)
                            {
                                //Display warning mesg(if any)
                                if (periodDetailsReturnValue.PeriodStatus == 3 && displayWarnings)
                                {
                                    _mdlPopUpCofirmationBox.Show();
                                    return;
                                }

                                if (periodDetailsReturnValue.PeriodStatus == 2)
                                {
                                    throw new Exception(periodDetailsReturnValue.ErrorMessage);
                                }

                                if (timeSheetItem != null)
                                {
                                    bool canBePosted = true;

                                    if (timeSheetItem.BillingTypeActive &&
                                        timeSheetItem.BillingTypeArchived == false &&
                                        timeSheetItem.TimeLAAsked == false)
                                    {
                                        canBePosted = false;
                                    }

                                    if (canBePosted)
                                    {
                                        TimeSheet timeSheet = new TimeSheet();
                                        timeSheet.TimeId = timeSheetItem.TimeId;
                                        timeSheet.PeriodId = periodDetailsReturnValue.PeriodId;
                                        timeSheet.MemberId = timeSheetItem.MemberId.ToString();
                                        timeSheet.CurrencyId = timeSheetItem.CurrencyId;
                                        timeSheet.PeriodMinutes = timeSheetItem.TimeElapsed;
                                        timeSheet.MasterPostedCost = timeSheetItem.TimeCost;
                                        timeSheet.MasterPostedCharge = timeSheetItem.TimeCharge;
                                        timeSheet.WorkingPostedCost = timeSheetItem.TimeCost;
                                        timeSheet.WorkingPostedCharge = timeSheetItem.TimeCharge;
                                        timeSheet.OrganisationId = timeSheetItem.OrganisationId;
                                        timeSheet.DepartmentId = timeSheetItem.DepartmentId;
                                        timeSheet.ProjectId = timeSheetItem.ProjectId;
                                        timeSheet.TimeTypeId = timeSheetItem.TimeTypeId;
                                        timeSheet.TimeDate = timeSheetItem.TimeDate;

                                        ReturnValue returnVal = timeService.PostTime(_logonSettings.LogonId, timeSheet);
                                        if (!returnVal.Success)
                                        {
                                            throw new Exception(returnVal.Message);
                                        }
                                    }
                                }

                            }
                            else
                            {
                                throw new Exception(periodDetailsReturnValue.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
                if (earnerService != null)
                {
                    if (earnerService.State != System.ServiceModel.CommunicationState.Faulted)
                        earnerService.Close();
                }
            }
        }
        public ActionResult Edit( TimeSheet.Models.Event aEvent)
        {
            if (!this.ModelState.IsValid)
            {
                return View();
            }

            rep.Save(aEvent);
            ViewBag.Message = "Event wurde gespeichert";
            return View(aEvent);
        }
        public int UpdateTimeSheet(TimeSheet timeSheet)
        {
            TimeSheet ts = dB.TimeSheets.Where(t => t.Id == timeSheet.Id).FirstOrDefault();

            ts.LastUpdateDate = timeSheet.LastUpdateDate;
            ts.Rate           = timeSheet.Rate;

            ts.UserID      = timeSheet.UserID;
            ts.Cost        = timeSheet.Cost;
            ts.Description = timeSheet.Description;

            dB.TimeSheets.Attach(ts);
            dB.Entry(ts).State = EntityState.Modified;

            return(dB.SaveChanges());
        }
Example #4
0
        internal TimeSheet GetTimeFile(int DayInt)
        {
            if (!_timesheetdictionary.ContainsKey(DayInt))
            {
                lock (_object)
                {
                    if (!_timesheetdictionary.ContainsKey(DayInt))
                    {
                        TimeSheet time = new TimeSheet(DayInt, this);
                        _timesheetdictionary.Add(DayInt, time);
                    }
                }
            }

            return(_timesheetdictionary[DayInt]);
        }
Example #5
0
        public virtual TimeSheet GetTimeSheetDefine(HttpContext context)
        {
            YZRequest request   = new YZRequest(context);
            string    sheetName = request.GetString("sheetName");

            TimeSheet timesheet;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                timesheet = TimeSheet.Load(cn, sheetName);
                timesheet.Data.Clear();
            }

            return(timesheet);
        }
        private TimeSheet CreateTimeSheet(string id)
        {
            var timesheet  = new TimeSheet();
            var userRecord = _userManager.FindByIdAsync(id);

            timesheet.UserId             = id;
            timesheet.StartDate          = DateTime.Today.StartOfWeek(DayOfWeek.Monday);
            timesheet.EndDate            = timesheet.StartDate.AddDays(6);
            timesheet.ExemptFromOvertime = userRecord.Result.ExemptFromOvertime;

            //need to call save changes
            _context.TimeSheets.Add(timesheet);
            _context.SaveChanges();

            return(timesheet);
        }
Example #7
0
        public void TimeSheetService_GetById_NotExist()
        {
            TimeSheet timeSheet = Builder <TimeSheet> .CreateNew().Build();

            TimeSheet timeSheetResponse = null;

            // Arrange
            mockTimeSheetRepository.Setup(m => m.GetById(timeSheet.TimeSheetId)).Returns(timeSheetResponse);

            // Act
            var result = timeSheetService.GetById(timeSheet.TimeSheetId);

            // Assert
            mockTimeSheetRepository.Verify(m => m.GetById(timeSheet.TimeSheetId), Times.Once);
            Assert.Null(result);
        }
        public void Save(TimeSheet.Models.Event aEvent)
        {
            var eventInDb = FindById(aEvent.Id);

            if(eventInDb != null)
            {
                eventInDb.Description = aEvent.Description;
                eventInDb.StartTime = aEvent.StartTime;
                eventInDb.StopTime = aEvent.StopTime;
            }
            else
            {
                aEvent.Id = Events.Max(h => h.Id) + 1;
                Events.Add(aEvent);
            }
        }
        public void SetUp()
        {
            _timeSheet = null;

            var mocks = new MockRepository();
            var repository = mocks.Stub<IDomainRepository>();
            Expect.Call(() => repository.Add<TimeSheet>(null))
                .IgnoreArguments()
                .WhenCalled(i => _timeSheet = i.Arguments[0] as TimeSheet);
            mocks.ReplayAll();

            _startDate = DateTime.Today;
            var createTimeSheet = new CreateTimeSheet(_startDate);
            var handler = new CreateTimeSheetHandler(repository);
            handler.Execute(createTimeSheet);
        }
Example #10
0
        public ActionResult SubmitOldTimesheet(TimeSheet model)
        {
            Employee         emp     = (Employee)Session["Employee"];
            List <TimeSheet> tsheets = (List <TimeSheet>)Session["TimeSheetData"];

            foreach (TimeSheet sheet in tsheets)
            {
                sheet.Submitted = "True";
                sheet.UpdateTimeSheet(sheet);
            }
            string message = "Your time sheet was successfully submitted.";

            Session["OldMessage"] = message;

            return(RedirectToAction("OldTimesheet", "Timesheet"));
        }
 public void AddNewSheet(TimeSheet timeSheetModel)
 {
     context.TimeSheets.Add(new TimeSheet
     {
         Month        = timeSheetModel.Month,
         ProjectHours = timeSheetModel.ProjectHours,
         Overwork     = timeSheetModel.Overwork,
         Sick         = timeSheetModel.Sick,
         Absence      = timeSheetModel.Absence,
         Training     = timeSheetModel.Training,
         Other        = timeSheetModel.Other,
         Data         = timeSheetModel.Data,
         Comment      = timeSheetModel.Comment
     });
     context.SaveChanges();
 }
        public void EditTimeEntry()
        {
            TestData Data = DataManager.GetTestData("TimeSheetData", DataRandomToken, TestRunNum);

            Login login = new Login(this.DriverManager);

            login.OpenApp().LogIn(Data.Get("Login"), 1);

            Dashboard dashboard = new Dashboard(this.DriverManager);

            dashboard.OpenSideMenu("Client Central");//.OpenMenu("TimeSheets");

            TimeSheet ts = new TimeSheet(this.DriverManager);

            ts.EditTimeSheet(Data);
        }
        public void TimeSheetServiceShouldAddNewTimeSheet()
        {
            var _newTimeSheet = new TimeSheet()
            {
                TaskNo     = 210,
                HandleDate = DateTime.Parse("2019-09-25"),
                WorkHours  = 1.5
            };

            int maxTimeSheetID = _timesheets.Max(t => t.TimesheetID);

            _newTimeSheet.TimesheetID = maxTimeSheetID + 1;
            _timesheetService.Add(_newTimeSheet);

            Assert.That(_newTimeSheet, Is.EqualTo(_timesheets.Last()));
        }
Example #14
0
        // GET: TimeSheets
        public async Task <ActionResult> Index()
        {
            ViewBag.Current  = "TutorTimeSheets";
            ViewBag.MonthsID = new SelectList(viewBagTS.getMonths(), "Key", "Value");
            ViewBag.TutorID  = new SelectList(db.Tutors, "ID", "VNumber");
            ViewBag.DaysID   = new SelectList(viewBagD.getDays(), "Key", "Value");

            if (getRole() == "T")
            {
                var tutor          = getUser();
                var returningTutor = getUser().Tutor;

                TutorTimeSheetCustomModel tsData = new TutorTimeSheetCustomModel();

                tsData.TimeSheets = db.TimeSheets
                                    .Where(t => t.TutorID == tutor.ID)
                                    .OrderByDescending(y => y.Year)
                                    .OrderByDescending(m => m.Month)
                                    .ToList();

                tsData.tutor = returningTutor;
                Day d = new Day();
                tsData.days = d.getDays();
                TimeSheet ts = new TimeSheet();
                tsData.months = ts.getMonths();

                return(View(tsData));
            }
            else if (getRole() == "A")
            {
                TutorTimeSheetCustomModel tsData = new TutorTimeSheetCustomModel();

                tsData.TimeSheets = db.TimeSheets.Include(t => t.Tutor)
                                    .OrderByDescending(y => y.Year)
                                    .OrderByDescending(m => m.Month)
                                    .ToList();

                Day d = new Day();
                tsData.days = d.getDays();
                TimeSheet ts = new TimeSheet();
                tsData.months = ts.getMonths();

                return(View(tsData));
            }

            return(View("error"));
        }
        public ActionResult Checkout(string id)
        {
            DateTime datenow    = DateTime.Now;
            int      employeeid = Convert.ToInt32(id);

            List <TimeSheet> time = db.TimeSheets.Where(a => a.Emp_ID == employeeid).ToList();

            if (time.Count != 0)
            {
                List <string> Year = new List <string>();
                //here we look at each item to see if they checked in attribute is same as today date.
                foreach (var item in time)
                {
                    //for each item we need to look for the one that has no checkout value but has a checkin value that has same day
                    DateTime checkin    = (DateTime)item.Check_in;//here we get the date
                    string   storeddate = checkin.ToString("MM/dd/yyyy");
                    string   today      = datenow.ToString("MM/dd/yyyy");
                    //here we compare the current item date with today's date
                    if (storeddate == today)
                    {
                        //the date we get here is the one from checkout to see if teh re is a checkout date already
                        DateTime checkout = (DateTime)item.Check_out;
                        string   pastdate = checkout.ToString("MM/dd/yyyy");
                        if (pastdate == today)
                        {
                            Year.Add(today);
                        }
                    }
                }//I use this to see if the list is populated if is then the peron has already checked in today
                if (Year.Count == 0)
                {
                    TimeSheet timeSheet = new TimeSheet();
                    timeSheet.Emp_ID   = employeeid;
                    timeSheet.Check_in = datenow;
                    db.TimeSheets.Add(timeSheet);
                    db.SaveChanges();
                    return(RedirectToAction("Checkout"));
                }
                else
                {
                }
            }
            else
            {
            }
            return(View());
        }
Example #16
0
        public IList <TimeSheet> FetchDataBasedOnDate(string AssociateId, DateTime date)
        {
            SqlDatabase      sqlConn;
            DbCommand        databaseCommand;
            List <TimeSheet> DateAndDays = null;

            try
            {
                sqlConn                     = new SqlDatabase(ConnectionInfo.GetConnectionString);
                databaseCommand             = sqlConn.GetStoredProcCommand("TS_FetchDataBasedOnMonth");
                databaseCommand.CommandType = CommandType.StoredProcedure;
                //Parameters
                sqlConn.AddInParameter(databaseCommand, "@UserName", SqlDbType.VarChar, AssociateId);
                sqlConn.AddInParameter(databaseCommand, "@DateandTime", SqlDbType.DateTime, date);
                using (IDataReader databaseReader = sqlConn.ExecuteReader(databaseCommand))
                {
                    DateAndDays = new List <TimeSheet>();
                    while (databaseReader.Read())
                    {
                        /////// creating object of UnbudgetedLoad class
                        TimeSheet OTimeSheet = CreateObject.GetObject <TimeSheet>();
                        OTimeSheet.Date               = Convert.ToInt32(databaseReader["Date"]);
                        OTimeSheet.Days               = Convert.ToString(databaseReader["Days"]);
                        OTimeSheet.DateWorked         = Convert.ToString(databaseReader["DateWorked"]);
                        OTimeSheet.TimesheetPeriodid  = Convert.ToInt32(databaseReader["TimesheetPeriodid"]);
                        OTimeSheet.RequestId          = Convert.ToString(databaseReader["RequestId"]);
                        OTimeSheet.ProjectHoursWorked = Convert.ToString(databaseReader["ProjectHoursWorked"]);
                        DateAndDays.Add(OTimeSheet);
                    }
                }

                return(DateAndDays);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlConn         = null;
                databaseCommand = null;
            }
        }
        /// <summary>
        /// Updates a score in the file.
        /// </summary>
        /// <param name="timeSheetToUpdate">The time sheet to update.</param>
        /// <returns></returns>
        public async Task <Result <TimeSheet> > UpdateAsync(TimeSheet timeSheetToUpdate)
        {
            if (timeSheetToUpdate == null)
            {
                return(Error <TimeSheet>(null, new ArgumentNullException(nameof(timeSheetToUpdate), $"{nameof(timeSheetToUpdate)} cannot be null.")));
            }

            if (!string.IsNullOrEmpty(timeSheetToUpdate.Id))
            {
                return(Error <TimeSheet>(null, new ArgumentOutOfRangeException(nameof(timeSheetToUpdate), "The time sheet passed in does not have a valid id.")));
            }

            var allTimeSheets = (await GetAll <TimeSheet>()) ?? new List <TimeSheet>();

            if (allTimeSheets == null ||
                allTimeSheets.Count < 1 ||
                allTimeSheets.Where(c => c.Id != timeSheetToUpdate.Id).FirstOrDefault() == null)
            {
                return(Error <TimeSheet>(null, new Exception("A time sheet with that name and id could not be found.")));
            }

            // Grab all of the time sheets w/o the id passed in.
            var newPilotList = allTimeSheets.Where(c => c.Id != timeSheetToUpdate.Id).ToList();

            newPilotList.Add(timeSheetToUpdate);

            var result = false;

            try
            {
                // Write the new pilot list.
                result = await WriteAll(newPilotList);
            }
            catch (Exception ex)
            {
                return(Error <TimeSheet>(null, ex));
            }

            if (!result)
            {
                return(Error <TimeSheet>(null, $"An error occured when updating the time sheet with id {timeSheetToUpdate.Id}."));
            }
            else
            {
                return(Success(timeSheetToUpdate, nameof(UpdateAsync)));
            }
        }
        static void Main()
        {
            using (var Site = new SPSite("http://epm2007demo/pwa03"))
            {
                var Timesheet_Svc = new TimeSheet
                {
                    UseDefaultCredentials = true,
                    AllowAutoRedirect     = true,
                    Url = (Site.Url + "/_vti_bin/psi/timesheet.asmx")
                };

                var jobUID       = Guid.NewGuid();
                var tsUID        = Guid.NewGuid();
                var nextapprover = Guid.NewGuid();
                Timesheet_Svc.QueueReviewTimesheet(jobUID, tsUID, nextapprover, "Approving using utility", ITXProjectsLibrary.WebSvcTimeSheet.Action.Approve);
            }
        }
        private void OnSheetParsed(object sender, TimeSheet timeSheet)
        {
            var goBackCommand = new ButtonCommand(_navigationService.GoBack);

            var dateSelectionViewModel = new CompleteInformationViewModel(timeSheet, goBackCommand);

            dateSelectionViewModel.TimeSheetCompleted += (s, ea) =>
            {
                if (ea.DateRange.HasValue)
                {
                    timeSheet.Period = ea.DateRange;
                }
                OnTimeSheetCreated(new TimeSheetCreatedEventArgs(timeSheet, ea.WorkContract));
            };

            _navigationService.Navigate(new CompleteInformationPage(dateSelectionViewModel));
        }
            public void TestCleanup()
            {
                if (File.Exists(timesheetpath))
                {
                    File.Delete(timesheetpath);
                }

                if (File.Exists(employeepath))
                {
                    File.Delete(employeepath);
                }

                timeSheet   = null;
                employees   = null;
                weekDetails = null;
                EmployeeBook.ClearInstance();
            }
Example #21
0
        //This controller obtains a list of pay summary objects for the week selected in the UI
        public ActionResult GetPayData(TimeSheet model)
        {
            List <WeeklyReport> paySumList = new List <WeeklyReport>();
            WeeklyReport        paySum     = new WeeklyReport();
            var        wED    = model.WeekEnding;
            List <int> empIds = paySum.GetBanner_IDsByWeekEndDate(wED);

            foreach (int empId in empIds)
            {
                paySumList.Add(paySum.getWeeklyReport(empId, wED));
            }

            Session["Weekend"]        = wED;
            Session["PaySummaryList"] = paySumList;

            return(RedirectToAction("Index", "HR"));
        }
        static void Main()
        {
            using (var Site = new SPSite("http://epm2007demo/pwa03"))
            {
                var Timesheet_Svc = new TimeSheet
                                        {
                                            UseDefaultCredentials = true,
                                            AllowAutoRedirect = true,
                                            Url = (Site.Url + "/_vti_bin/psi/timesheet.asmx")
                                        };

                var jobUID = Guid.NewGuid();
                var tsUID = Guid.NewGuid();
                var nextapprover = Guid.NewGuid();
                Timesheet_Svc.QueueReviewTimesheet(jobUID, tsUID, nextapprover, "Approving using utility", ITXProjectsLibrary.WebSvcTimeSheet.Action.Approve);
            }
        }
Example #23
0
        public IHttpActionResult PostTimeSheet(TimeSheet timeSheet)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // go ahead and lookup the currently signed-in user and add them to this timesheet
            var id = ClaimsPrincipal.Current.GetUserProperty(IdentityHelpers.PERSON_ID_K);

            timeSheet.volunteerId = id;

            db.TimeSheets.Add(timeSheet);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = timeSheet.Id }, timeSheet));
        }
Example #24
0
        /// <summary>
        /// 签到,签退页面
        /// </summary>
        /// <returns></returns>
        public ActionResult CheckOrSignBack()
        {
            Model.EmployeeInfo em = (Model.EmployeeInfo)Session["Employeer"];

            //根据id查询考勤表(一条)
            TimeSheet tse = dal.GetTimeSheetByUserID(em.ID);

            if (tse == null)
            {
                ViewBag.timeinfo = null;
            }
            else
            {
                ViewBag.timeinfo = tse;
            }
            return(View());
        }
        /// <summary>
        /// Post todays time sheets for accounting
        /// </summary>
        /// <param name="oHostSecurityToken">User token</param>
        /// <param name="timeSheet">Fee Earner Time Sheet</param>
        /// <returns></returns>
        public ReturnValue PostTime(HostSecurityToken oHostSecurityToken, TimeSheet timeSheet)
        {
            ReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oTimeService = new TimeService();
                returnValue  = oTimeService.PostTime(Functions.GetLogonIdFromToken(oHostSecurityToken), timeSheet);
            }
            else
            {
                returnValue         = new ReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
        public async void TimeSheet_GetById_Success()
        {
            var id = Guid.Parse("a358d10d-521e-4e3c-a1e2-077d4018087b");

            // Act
            var response = await client.GetAsync(BasePath + "getbyid?id=" + id);

            TimeSheet timeSheet = await response.Content.ReadAsAsync <TimeSheet>();

            // Assert1
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            Assert.True(timeSheet.TimeSheetId == id);
            // Assert2
            Assert.Equal("application/json; charset=utf-8",
                         response.Content.Headers.ContentType.ToString());
        }
Example #27
0
        /// <summary>
        /// 签退
        /// </summary>
        /// <returns></returns>
        public ActionResult AddCheckout()
        {
            Model.EmployeeInfo em = (Model.EmployeeInfo)Session["Employeer"];

            //根据id查询考勤表
            TimeSheet tse = dal.GetTimeSheetByUserID(em.ID);

            if (tse != null && tse.SignBackTime != null)//已经签退
            {
                return(Content("1"));
            }
            else
            {
                //根据id查询考勤表
                TimeSheet checkedin = dal.GetTimeSheetByUserID(em.ID);
                //是否已经签到
                if (checkedin == null)
                {
                    return(Content("0"));
                }
                else
                {
                    DateTime dt        = DateTime.Now;
                    double   totaltime = dt.TimeOfDay.TotalHours;//将时间转换成小时
                    Session["detailcheckout"] = totaltime;
                    Session["checkout"]       = dt.TimeOfDay.ToString().Substring(0, 5);

                    //根据id查询考勤表
                    TimeSheet ts = dal.GetTimeSheetByUserID(em.ID);
                    ts.SignBackTime = Session["checkout"].ToString();

                    if (Convert.ToDouble(Session["detailcheckout"]) < 17.5)
                    {
                        ts.SignBackType = 1;
                        ts.Remark      += "早退";
                    }
                    else if (Convert.ToDouble(Session["detailcheckout"]) > 17.5)
                    {
                        ts.SignBackType = 0;
                        ts.Remark      += "迟退";
                    }
                    isIn = dal.UpdCheck(ts);
                    return(RedirectToAction("CheckOrSignBack"));
                }
            }
        }
        public async Task <IActionResult> Upsert(int?id)
        {
            var obj = new TimeSheet();

            if (id == null)
            {
                return(View(obj));
            }

            obj = await _timeSheetRepository.GetAsync(SD.TimeSheetAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
        public IActionResult save([FromBody] AddTimeSheet items)
        {
            try
            {
                TimeSheet timeSheet = new TimeSheet();


                var existingEmployeee = db.TimeSheet.FirstOrDefault(item => items.Empid == item.Empid);
                if (existingEmployeee == null)
                {
                    timeSheet.Empid   = items.Empid;
                    timeSheet.Empname = items.Empname;
                    db.Add(timeSheet);
                    db.SaveChanges();
                }
                foreach (TimeSheetData value in items.data)
                {
                    TimeSheetItem  timeSheetItem  = new TimeSheetItem();
                    TimeSheetEntry timeSheetEntry = new TimeSheetEntry();
                    timeSheetItem.Hours       = value.Hours;
                    timeSheetItem.Empid       = items.Empid;
                    timeSheetItem.Status      = "Drafted";
                    timeSheetItem.Submittedto = value.Submittedto;
                    timeSheetItem.To          = items.To;
                    timeSheetItem.From        = items.From;
                    timeSheetItem.Date        = value.Date;
                    db.Add(timeSheetItem);
                    db.SaveChanges();
                    int index = timeSheetItem.Timestampid;

                    timeSheetEntry.Customer    = value.Customer;
                    timeSheetEntry.Company     = value.Company;
                    timeSheetEntry.Task        = value.Task;
                    timeSheetEntry.Project     = value.Project;
                    timeSheetEntry.Timestampid = index;

                    db.Add(timeSheetEntry);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
            }
            return(Ok());
        }
Example #30
0
        public void SummaryCalculationWithVacations()
        {
            var timeSheet = new TimeSheet()
            {
                //21 week days in the month
                Period      = new DateRange(new DateTime(2018, 12, 1), new DateTime(2018, 12, 31)),
                TimeEntries = new List <TimeEntry>()
                {
                    new TimeEntry()
                    {
                        Duration = TimeSpan.FromHours(6 * 7),
                        Client   = "Mock Client",
                        Project  = "Normal project"
                    }
                }
            };

            var timeOff = new List <TimeOff>()
            {
                new TimeOff()
                {
                    //11 workdays on vacations, 15 total days on vacations
                    Period      = new DateRange(new DateTime(2018, 12, 7), new DateTime(2018, 12, 21)),
                    Description = "Vacations"
                },
                new TimeOff()
                {
                    //Overlapping with vacations, so it shouldn't affect the calculations
                    Period      = new DateRange(new DateTime(2018, 12, 11), new DateTime(2018, 12, 13)),
                    Description = "No clients scheduled"
                },
                new TimeOff()
                {
                    //3 days off
                    Period      = new DateRange(new DateTime(2018, 12, 24), new DateTime(2018, 12, 26)),
                    Description = "Christmas!"
                }
            };

            var summary = TimeSummaryCalculator.CalculateHoursSummary(TimeSpan.FromHours(6), timeSheet, timeOff);

            Assert.AreEqual(timeSheet.Period, summary.Period);
            Assert.AreEqual(TimeSpan.FromHours(6 * 7), summary.PlannedWork);
            Assert.AreEqual(TimeSpan.FromHours(6 * 7), summary.TimeWorked);
            Assert.AreEqual(TimeSpan.Zero, summary.WorkTimeBalance);
        }
 public void Post([FromBody] TimeSheetModel timesheet)
 {
     //Server-side validation
     if (ModelState.IsValid)
     {
         //Create Entity from validated data
         var toAdd = new TimeSheet
         {
             EmployeeName = timesheet.EmployeeName,
             Date         = timesheet.Date,
             HoursWorked  = timesheet.HoursWorked
         };
         //Add to EntityFramework here
         _context.TimeSheets.Add(toAdd);
         _context.SaveChanges();
     }
 }
Example #32
0
        public TimeSheet Add(TimeSheet timeSheet)
        {
            var response       = this.timeSheetRepository.Add(timeSheet);
            var notifyResponse = this.timeSheetRepository.Notify(response.TimeSheetId);

            response.Messages = new List <string>();
            if (notifyResponse == null)
            {
                response.Messages.Add("Não foi possível enviar a notificação");
            }
            else
            {
                response.Messages.Add(notifyResponse.Result.message);
            }

            return(response);
        }
Example #33
0
        protected void Approve_Click(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string siteurl = MyConfiguration.GetSiteURL(SPContext.Current);

                var Resource_Svc = new Resource();
                Resource_Svc.AllowAutoRedirect     = true;
                Resource_Svc.UseDefaultCredentials = true;
                Resource_Svc.Url = siteurl + "/_vti_bin/psi/resource.asmx";

                var Timesheet_Svc = new TimeSheet();
                Timesheet_Svc.AllowAutoRedirect     = true;
                Timesheet_Svc.UseDefaultCredentials = true;
                Timesheet_Svc.Url = siteurl + "/_vti_bin/psi/timesheet.asmx";

                string[] selectedtsuids = Request.Form["LstSelectedtsuids"].Split('#');
                if (selectedtsuids.Length > 0)
                {
                    var grouped_tsuids = (from c in selectedtsuids
                                          group c by c).ToList();
                    foreach (IGrouping <string, string> tsuid_str in grouped_tsuids)
                    {
                        if (tsuid_str.Key != string.Empty)
                        {
                            try
                            {
                                var tsuid        = new Guid(tsuid_str.Key);
                                var jobUID       = Guid.NewGuid();
                                var nextapprover = Resource_Svc.GetCurrentUserUid();
                                Timesheet_Svc.QueueReviewTimesheet(jobUID, tsuid, nextapprover,
                                                                   "Approving using utility",
                                                                   ITXProjectsLibrary.WebSvcTimeSheet.Action.Approve);
                            }
                            catch (Exception ex)
                            {
                                MyConfiguration.ErrorLog("Error at approving timesheet due to " + ex.Message,
                                                         EventLogEntryType.Error);
                            }
                        }
                    }
                }
                LblStatus.Text = "Timesheet approval process completed successfully.";
            }
        }
        protected void Approve_Click(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string siteurl = MyConfiguration.GetSiteURL(SPContext.Current);

                var Resource_Svc = new Resource();
                Resource_Svc.AllowAutoRedirect = true;
                Resource_Svc.UseDefaultCredentials = true;
                Resource_Svc.Url = siteurl + "/_vti_bin/psi/resource.asmx";

                var Timesheet_Svc = new TimeSheet();
                Timesheet_Svc.AllowAutoRedirect = true;
                Timesheet_Svc.UseDefaultCredentials = true;
                Timesheet_Svc.Url = siteurl + "/_vti_bin/psi/timesheet.asmx";

                string[] selectedtsuids = Request.Form["LstSelectedtsuids"].Split('#');
                if (selectedtsuids.Length > 0)
                {
                    var grouped_tsuids = (from c in selectedtsuids
                                          group c by c).ToList();
                    foreach (IGrouping<string, string> tsuid_str in grouped_tsuids)
                    {
                        if (tsuid_str.Key != string.Empty)
                        {
                            try
                            {
                                var tsuid = new Guid(tsuid_str.Key);
                                var jobUID = Guid.NewGuid();
                                var nextapprover = Resource_Svc.GetCurrentUserUid();
                                Timesheet_Svc.QueueReviewTimesheet(jobUID, tsuid, nextapprover,
                                                                   "Approving using utility",
                                                                   ITXProjectsLibrary.WebSvcTimeSheet.Action.Approve);
                            }
                            catch (Exception ex)
                            {
                                MyConfiguration.ErrorLog("Error at approving timesheet due to " + ex.Message,
                                                         EventLogEntryType.Error);
                            }
                        }
                    }
                }
                LblStatus.Text = "Timesheet approval process completed successfully.";
            }
        }
Example #35
0
        //This is a funtion that handles generating User Information
        static public TimeSheet GetUserData(string overrideUser, Page myPage)
        {
            TimeSheet myTimesheet = new TimeSheet();
            string    user        = myPage.User.Identity.Name.Replace(@"CCSO\", "").ToUpper();
            string    oldUser     = "";
            string    overrideSessionContent;

            if (!overrideUser.Equals(""))
            {
                oldUser = user;
                user    = overrideUser;
            }
            else if (HttpContext.Current.Session["override"] != null)
            {
                overrideSessionContent = HttpContext.Current.Session["override"].ToString();
                if (!overrideSessionContent.Equals(""))
                {
                    user = HttpContext.Current.Session["override"].ToString();
                }
            }

            myTimesheet.SetTimesheet(DateTime.Now.ToShortDateString(), user);

            //if (!myTimesheet.MemberInforamtion.UserActive)
            //HttpContext.Current.Response.Redirect("Error_Page.aspx", true);

            HttpContext.Current.Session["currentMemberTimesheet"]   = myTimesheet;
            HttpContext.Current.Session["currentMemberInformation"] = myTimesheet.MemberInforamtion;
            HttpContext.Current.Session["currentMemberWorkCode"]    = myTimesheet.MemberInforamtion.WorkCodes;

            if (!myPage.Request.Url.AbsoluteUri.Contains("Permissions"))
            {
                HttpContext.Current.Session["currentMemberPosNum"] = myTimesheet.MemberInforamtion.PosNumber.Trim();
            }

            //myPage fills out user work codes on initial load. make sure to heck if we are overriding a user to get their supervisors
            if (Convert.ToString(HttpContext.Current.Session["supDTCheck"]).Equals("") || !user.Equals(oldUser))
            {
                HttpContext.Current.Session["supDTCheck"] = "TRUE";
            }

            HttpContext.Current.Session["supervisorDataTable"] = DBAssist.FillSupervisorDropdown(osn: myTimesheet.MemberInforamtion.MemberOSN.ToString());

            return(myTimesheet);
        }
 public bool InsertTimeSheet(int EmployeeID, int WorkDay, int Total, string Currency)
 {
     try
     {
         TimeSheet timeSheet = new TimeSheet();
         timeSheet.EmployeeID  = EmployeeID;
         timeSheet.TotalDay    = WorkDay;
         timeSheet.TotalAmount = Total;
         timeSheet.Currency    = Currency;
         context.TimeSheets.InsertOnSubmit(timeSheet);
         context.SubmitChanges();
         return(true);
     }
     catch (Exception e)
     {
         throw new Exception("Error insert timeSheet: " + e.Message);
     }
 }
 /// <summary>
 /// Post todays time sheets for accounting 
 /// </summary>
 /// <param name="oHostSecurityToken">User token</param>
 /// <param name="timeSheet">Fee Earner Time Sheet</param>
 /// <returns></returns>
 public ReturnValue PostTime(HostSecurityToken oHostSecurityToken, TimeSheet timeSheet)
 {
     ReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oTimeService = new TimeService();
         returnValue = oTimeService.PostTime(Functions.GetLogonIdFromToken(oHostSecurityToken), timeSheet);
     }
     else
     {
         returnValue = new ReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }