示例#1
0
        private void FillReport(bool isInitial = false, bool throwException = true)
        {
            ReportCompositeRequest req = GetRequest();

            ListResponse <Model.Reports.RT301> resp = _reportsService.ChildGetAll <Model.Reports.RT301>(req);

            //if (!resp.Success)
            //{
            //    throw new Exception(resp.Error + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + resp.LogId + "</br>");
            //}
            if (!resp.Success)
            {
                Common.ReportErrorMessage(resp, GetGlobalResourceObject("Errors", "Error_1").ToString(), GetGlobalResourceObject("Errors", "ErrorLogId").ToString());
            }


            List <Model.Reports.DailyAttendance> atts = new List <Model.Reports.DailyAttendance>();

            resp.Items.ForEach(x => atts.Add(new Model.Reports.DailyAttendance()
            {
                name               = x.name,
                branchName         = x.branchName,
                departmentName     = x.departmentName,
                Date               = DateTime.ParseExact(x.dayId, "yyyyMMdd", new CultureInfo("en")),
                lateness           = x.OL_A_SIGN[0] == '-' ? (new TimeSpan(Convert.ToInt32(x.OL_A.Substring(1, 2)), -Convert.ToInt32(x.OL_A.Substring(4, 2)), 0)) : (new TimeSpan(Convert.ToInt32(x.OL_A.Substring(0, 2)), Convert.ToInt32(x.OL_A.Substring(3, 2)), 0)),
                early              = x.OL_D_SIGN[0] == '-' ? (new TimeSpan(Convert.ToInt32(x.OL_D.Substring(1, 2)), Convert.ToInt32(x.OL_D.Substring(4, 2)), 0)) : (new TimeSpan(Convert.ToInt32(x.OL_D.Substring(0, 2)), Convert.ToInt32(x.OL_D.Substring(3, 2)), 0)),
                workingHours       = new TimeSpan(Convert.ToInt32(x.workingTime.Substring(0, 2)), Convert.ToInt32(x.workingTime.Substring(3, 2)), 0),
                workingHoursString = x.workingTime,
                earlyString        = x.OL_D,
                latenessString     = x.OL_A
            }));
            atts.ForEach(x => { x.DOW = GetGlobalResourceObject("Common", x.Date.DayOfWeek.ToString() + "Text").ToString(); x.DateString = x.Date.ToString(_systemService.SessionHelper.GetDateformat(), CultureInfo.CurrentUICulture); });


            DailyAttendance h = new DailyAttendance();

            h.RightToLeft       = _systemService.SessionHelper.CheckIfArabicSession() ? DevExpress.XtraReports.UI.RightToLeft.Yes : DevExpress.XtraReports.UI.RightToLeft.No;
            h.RightToLeftLayout = _systemService.SessionHelper.CheckIfArabicSession() ? DevExpress.XtraReports.UI.RightToLeftLayout.Yes : DevExpress.XtraReports.UI.RightToLeftLayout.No;
            h.DataSource        = atts;


            h.Parameters["From"].Value = DateTime.Parse(req.Parameters["_fromDate"]).ToString(_systemService.SessionHelper.GetDateformat());
            h.Parameters["To"].Value   = DateTime.Parse(req.Parameters["_toDate"]).ToString(_systemService.SessionHelper.GetDateformat());
            h.Parameters["User"].Value = _systemService.SessionHelper.GetCurrentUser();
            if (resp.Items.Count > 0)
            {
                if (req.Parameters["_employeeId"] != "0")
                {
                    h.Parameters["Employee"].Value = resp.Items[0].name;
                }
                else
                {
                    h.Parameters["Employee"].Value = GetGlobalResourceObject("Common", "All");
                }
            }
            h.CreateDocument();


            ASPxWebDocumentViewer1.DataBind();
            ASPxWebDocumentViewer1.OpenReport(h);
        }