コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static TimeSheetEventModel Update(TimeSheetEventModel model)
        {
            var entity = new hr_TimeSheetEvent();

            model.FillEntity(ref entity);
            entity.EditedDate = DateTime.Now;
            return(new TimeSheetEventModel(hr_TimeSheetEventServices.Update(entity)));
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static TimeSheetEventModel Create(TimeSheetEventModel model)
        {
            var entity = new hr_TimeSheetEvent();

            // fill
            model.FillEntity(ref entity);

            // create entity
            return(new TimeSheetEventModel(hr_TimeSheetEventServices.Create(entity)));
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private static TimeSheetEventModel FillObject(IDataRecord dr)
        {
            try
            {
                var model = new TimeSheetEventModel
                {
                    Id            = (int)dr["Id"],
                    RecordId      = (int)dr["RecordId"],
                    WorkShiftId   = (int)dr["WorkShiftId"],
                    GroupSymbolId = (int)dr["GroupSymbolId"],
                    SymbolId      = (int)dr["SymbolId"],
                    WorkConvert   = (double)dr["WorkConvert"],
                    TimeConvert   = (double)dr["TimeConvert"],
                    Type          = (TimeSheetAdjustmentType)(int)dr["Type"],
                    Description   = (string)dr["Description"],
                    Status        = (EventStatus)(int)dr["Status"],
                    IsDeleted     = (bool)dr["IsDeleted"],
                    // custom props
                    EmployeeCode       = (string)dr["EmployeeCode"],
                    FullName           = (string)dr["FullName"],
                    DepartmentName     = (string)dr["DepartmentName"],
                    GroupWorkShiftName = (string)dr["GroupWorkShiftName"],
                    WorkShiftName      = (string)dr["WorkShiftName"],
                    SymbolName         = (string)dr["SymbolName"],
                    SymbolCode         = (string)dr["SymbolCode"],
                    SymbolColor        = (string)dr["SymbolColor"],
                    GroupSymbolName    = (string)dr["GroupSymbolName"],
                    GroupSymbolGroup   = (string)dr["GroupSymbolGroup"]
                };

                if (!(dr["CreatedDate"] is DBNull))
                {
                    model.CreatedDate = (DateTime)dr["CreatedDate"];
                }
                if (!(dr["EditedDate"] is DBNull))
                {
                    model.EditedDate = (DateTime)dr["EditedDate"];
                }
                if (!(dr["StartDate"] is DBNull))
                {
                    model.StartDate = (DateTime)dr["StartDate"];
                }
                if (!(dr["EndDate"] is DBNull))
                {
                    model.EndDate = (DateTime)dr["EndDate"];
                }

                return(model);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error on fill object: " + ex.Message);
                return(new TimeSheetEventModel());
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="recordIds"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="start"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public static PageResult <TimeSheetEventSummaryModel> GetReportDetail(string keyword, string recordIds, DateTime?startDate, DateTime?endDate, int?start, int?limit)
        {
            // init object
            var startPage = 0;
            int limitPage;
            var resultModels  = new List <TimeSheetEventSummaryModel>();
            var listRecordIds = new List <string>();

            // string to list record id
            if (!string.IsNullOrEmpty(recordIds))
            {
                listRecordIds = recordIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
            }

            // caculate start limit page
            if (start != null)
            {
                startPage = (int)start;
            }
            if (limit != null && startPage + limit < listRecordIds.Count)
            {
                limitPage = (int)limit;
            }
            else
            {
                limitPage = listRecordIds.Count - startPage;
            }

            // paging by record id
            recordIds = string.Join(",", listRecordIds.GetRange(startPage, limitPage));

            //get all events
            var timeSheetEvents = GetAll(keyword, recordIds, null, null, null, null, false, null, startDate, endDate, null,
                                         null, null, null);

            foreach (var id in listRecordIds.GetRange(startPage, limitPage))
            {
                var timeSheetEvent = new TimeSheetEventModel();
                // get event by record id
                var listEventByRecord = timeSheetEvents.Where(ts => ts.RecordId == Convert.ToInt32(id)).ToList();
                if (listEventByRecord.Count > 0)
                {
                    timeSheetEvent = listEventByRecord.First();
                }
                else
                {
                    if (!string.IsNullOrEmpty(keyword))
                    {
                        continue;
                    }
                    // get record that has no event
                    var record = RecordController.GetById(Convert.ToInt32(id));
                    timeSheetEvent.RecordId       = record.Id;
                    timeSheetEvent.FullName       = record.FullName;
                    timeSheetEvent.EmployeeCode   = record.EmployeeCode;
                    timeSheetEvent.DepartmentName = record.DepartmentName;
                }

                var timeSheetEventSummary = new TimeSheetEventSummaryModel(listEventByRecord, startDate, endDate)
                {
                    RecordId       = timeSheetEvent.RecordId,
                    EmployeeCode   = timeSheetEvent.EmployeeCode,
                    FullName       = timeSheetEvent.FullName,
                    DepartmentName = timeSheetEvent.DepartmentName
                };
                // add summary to list summary
                resultModels.Add(timeSheetEventSummary);
            }

            return(new PageResult <TimeSheetEventSummaryModel>(listRecordIds.Count, resultModels));
        }