Пример #1
0
        public async Task <IHttpActionResult> GetNewParameter()
        {
            var unitCode    = _servicePeriod.GetCurrentUnitCode();
            var currentDate = DateTime.Now.Date;
            var result      = new ParameterLanDauKh()
            {
                ToDate   = currentDate.AddMonths(1).AddDays(-(currentDate.Day)),
                FromDate = currentDate.AddDays((-currentDate.Day) + 1),
                MinDate  = currentDate.AddDays((-currentDate.Day) + 1),
                MaxDate  = currentDate.AddMonths(1).AddDays(-(currentDate.Day)),
                UnitCode = unitCode
            };

            var periodCollection = _servicePeriod.Repository.DbSet.Where(x => x.UnitCode == unitCode && x.TrangThai == (int)ApprovalState.IsComplete);

            if (periodCollection != null && periodCollection.Count() > 0)
            {
                var lastPeriod     = periodCollection.OrderByDescending(x => x.Year).OrderByDescending(x => x.Period).FirstOrDefault();
                var originalPeriod = periodCollection.OrderBy(x => x.Period).FirstOrDefault();
                //result.MaxDate = lastPeriod.ToDate;
                //result.MinDate = originalPeriod.FromDate;
                //result.ToDate = lastPeriod.ToDate;
                //if (lastPeriod.ToDate.AddMonths(-1) >= originalPeriod.FromDate)
                //{
                //    result.FromDate = lastPeriod.ToDate.AddMonths(-1);
                //}
                //else
                //{
                //    result.FromDate = originalPeriod.FromDate;
                //}

                result.ToDate   = currentDate.AddMonths(1).AddDays(-(currentDate.Day));
                result.FromDate = currentDate.AddDays((-currentDate.Day) + 1);
                result.MinDate  = currentDate.AddDays((-currentDate.Day) + 1);
                result.MaxDate  = currentDate.AddMonths(1).AddDays(-(currentDate.Day));


                //result.MaxDay = lastPeriod.ToDate.Day;
                //result.MinDay = originalPeriod.FromDate.Day;
                //result.ToDay = lastPeriod.ToDate.Day;
                //result.FromDay = originalPeriod.ToDate.Day;
                //result.MonthOfBirth = lastPeriod.ToDate.Month;
            }

            return(Ok(result));
        }
Пример #2
0
        public async Task <IHttpActionResult> ReportLanDauKh(ParameterLanDauKh para)
        {
            ReportLanDauKh reporter = new ReportLanDauKh();

            try
            {
                var unitCode = _servicePeriod.GetCurrentUnitCode();
                reporter.FromDate    = para.FromDate;
                reporter.ToDate      = para.ToDate;
                reporter.CreateDate  = DateTime.Now;
                reporter.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
                reporter.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
                //GetNhanVien
                if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
                {
                    var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
                    var name        = currentUser.Identity.Name;
                    var nhanVien    = _service.UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
                    if (nhanVien != null)
                    {
                        reporter.Username = nhanVien.Username;
                    }
                    else
                    {
                        reporter.Username = "******";
                    }
                }
                reporter.DataDetails.AddRange(_service.ReportLanDauKh(para));
            }
            catch (Exception ex)
            {
            }
            return(Ok(reporter));



            //var result = new TransferObj<ReportLanDauKh>();
            //try
            //{
            //    var reporter = new ReportLanDauKh();
            //    //var data = new List<CustomLanDauKhReport>();
            //    reporter.UnitCode = _servicePeriod.GetCurrentUnitCode();
            //    var unitCode = _servicePeriod.GetCurrentUnitCode();

            //    reporter.FromDate = para.FromDate;
            //    reporter.ToDate = para.ToDate;
            //    reporter.CreateDate = DateTime.Now;
            //    reporter.TenDonVi = CurrentSetting.GetUnitName(unitCode);
            //    reporter.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
            //    //GetNhanVien
            //    if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
            //    {
            //        var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
            //        var name = currentUser.Identity.Name;
            //        var nhanVien = _service.UnitOfWork.Repository<AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
            //        if (nhanVien != null)
            //        {
            //            reporter.Username = nhanVien.TenNhanVien;
            //        }
            //        else
            //        {
            //            reporter.Username = "******";
            //        }
            //    }
            //    reporter.Data = _service.ReportLanDauKh(para);
            //    result.Data = reporter;
            //    result.Status = true;
            //    result.Message = "Xuất báo cáo thành công";
            //    return Ok(result);
            //}
            //catch (Exception e)
            //{
            //    return InternalServerError();
            //}
        }