private void FillReport(bool isInitial = false, bool throwException = true) { string rep_params = vals.Text; TimeAttendanceViewListRequest req = new TimeAttendanceViewListRequest(); req.paramString = rep_params; req.StartAt = "0"; req.Size = "1000"; req.sortBy = "dayId"; //ListResponse<AttendanceDay> resp = _timeAttendanceService.ChildGetAll<AttendanceDay>(req); ListResponse <Model.Reports.RT303> resp = _reportsService.ChildGetAll <Model.Reports.RT303>(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()); } bool rtl = _systemService.SessionHelper.CheckIfArabicSession(); resp.Items.ForEach(x => { x.dayId = DateTime.ParseExact(x.dayId, "yyyyMMdd", new CultureInfo("en")).ToString(_systemService.SessionHelper.GetDateformat()); } ); double OTL = 0; double OTO = 0; string getLan = _systemService.SessionHelper.getLangauge(); Dictionary <string, string> parameters = Web.UI.Forms.Common.FetchReportParameters(texts.Text); DetailedAttendance h = new DetailedAttendance(parameters, getLan); 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; List <Model.Reports.RT303> data = new List <Model.Reports.RT303>(); if (resp.Items.Count != 0) { Model.Reports.RT303 Item; resp.Items.ForEach(x => { Item = new Model.Reports.RT303(); Item.dayId = x.dayId; Item.employeeName = x.employeeName; Item.branchName = x.branchName; Item.effectiveTime = x.effectiveTime; if (x.firstPunch == null) { Item.firstPunch = "00:00"; } else { Item.firstPunch = x.firstPunch; } if (x.lastPunch == null) { Item.lastPunch = "00:00"; } else { Item.lastPunch = x.lastPunch; } Item.dayStatus = x.dayStatus; Item.totEffectiveTime = Convert.ToDouble(x.effectiveTime);//calculateTimeInMinutes(x.effectiveTime); if (x.LATE_CHECKIN == 0) { Item.lateCheckin = "00:00"; } else { Item.lateCheckin = time(Convert.ToInt32(x.LATE_CHECKIN), false); } //Item.lateCheckin = x.variationsList.Where(y => y.timeCode == 31).Count() != 0 ? time(x.variationsList.Where(y => y.timeCode == 31).First().duration, false) : "00:00"; //Item.duringShiftLeave = x.variationsList.Where(y => y.timeCode == 32).Count() != 0 ? time(x.variationsList.Where(y => y.timeCode == 32).First().duration, false) : ""; double dsl = 0; double totalLatness = 0; double totalOverTime = 0; double totEarlyCI = 0; double totlateCI = 0; double totEarlyLe = 0; double missedShift = 0; foreach (DetailedAttendanceVariation obj in x.variationsList) { if (obj.timeCode == 32) { dsl += obj.duration; } if (obj.timeCode == 31 || obj.timeCode == 33) { totalLatness += obj.duration; } if (obj.timeCode == 51 || obj.timeCode == 52) { totalOverTime += obj.duration; } if (obj.timeCode == 51) { totEarlyCI += obj.duration; } if (obj.timeCode == 31) { totlateCI += obj.duration; } if (obj.timeCode == 33) { totEarlyLe += obj.duration; } if (obj.timeCode == 21) { missedShift += obj.duration; } } Item.duringShiftLeave = x.DURING_SHIFT_LEAVE.ToString(); //dsl.ToString(); Item.totTotalLateness = x.NET_LATENESS; //totalLatness; Item.totTotalOvertime = x.NET_OVERTIME; // totalOverTime; Item.lineTotalOvertime = x.OVERTIME; //totalOverTime; Item.missedShift = x.SHIFT_LEAVE_WITHOUT_EXCUSE; //missedShift; Item.lineDuringShiftLeave = x.DURING_SHIFT_LEAVE; Item.lineEarlyCheckIn = x.EARLY_CHECKIN; //totEarlyCI; Item.lineLateCheckIn = x.LATE_CHECKIN; //totlateCI; Item.lineEarlyLeave = x.EARLY_LEAVE; Item.totTotalLateness = x.NET_LATENESS; Item.bTotTotalLateness = x.NET_LATENESS.ToString(); //totalLatness.ToString(); Item.bTotTotalOvertime = x.NET_OVERTIME.ToString(); //totalOverTime.ToString(); Item.strMissedShift = timeformat(Convert.ToInt32(x.SHIFT_LEAVE_WITHOUT_EXCUSE.ToString())); //missedShift//totalLatness.ToString(); Item.totalLateness = timeformat(Convert.ToInt32(x.NET_LATENESS)); //timeformat(Convert.ToInt32(totalLatness + dsl+missedShift));//totalLatness.ToString(); Item.totalOvertime = timeformat(Convert.ToInt32(x.NET_OVERTIME)); //timeformat(Convert.ToInt32(totalOverTime));//totalOverTime.ToString(); //Item.earlyLeave = x.variationsList.Where(y => y.timeCode == 33).Count() != 0 ? time(x.variationsList.Where(y => y.timeCode == 33).First().duration, false) : "00:00"; //Item.earlyCheckin = x.variationsList.Where(y => y.timeCode == 51).Count() != 0 ? time(x.variationsList.Where(y => y.timeCode == 51).First().duration, false) : "00:00"; if (x.EARLY_LEAVE == 0) { Item.earlyLeave = "00:00"; } else { Item.earlyLeave = time(Convert.ToInt32(x.EARLY_LEAVE), false); } if (x.EARLY_CHECKIN == 0) { Item.earlyCheckin = "00:00"; } else { Item.earlyCheckin = time(Convert.ToInt32(x.EARLY_CHECKIN), false); } if (x.OVERTIME == 0) { Item.overtime = "00:00"; } else { Item.overtime = time(Convert.ToInt32(x.OVERTIME), false); } //Item.overtime = time(Convert.ToInt32(x.netOvertime),false);//x.variationsList.Where(y => y.timeCode == 52).Count() != 0 ? time(x.variationsList.Where(y => y.timeCode == 52).First().duration, false) : ""; data.Add(Item); }); h.DataSource = data; } else { h.DataSource = resp.Items; } string user = _systemService.SessionHelper.GetCurrentUser(); h.Parameters["User"].Value = user; h.CreateDocument(); ASPxWebDocumentViewer1.OpenReport(h); ASPxWebDocumentViewer1.DataBind(); }
protected void TimeStore_ReadData(object sender, StoreReadDataEventArgs e) { try { //DashboardRequest req = GetDashboardRequest(); //DashboardTimeListRequest r = new DashboardTimeListRequest(); //r.fromDayId = dateRange1.GetRange().DateFrom.ToString("yyyyMMdd"); //r.toDayId = dateRange1.GetRange().DateTo.ToString("yyyyMMdd"); //r.dayId = ""; //r.employeeId = 0; //if (!string.IsNullOrEmpty(_systemService.SessionHelper.GetEmployeeId())) // r.approverId = Convert.ToInt32(_systemService.SessionHelper.GetEmployeeId()); //else //{ // TimeStore.DataSource = new List<Time>(); // TimeStore.DataBind(); // return; //} //r.timeCode = timeVariationType.GetTimeCode(); //r.shiftId = "0"; //r.apStatus = "1"; //r.BranchId = req.BranchId; //r.DivisionId = req.DivisionId; //r.PositionId = req.PositionId; //r.DepartmentId = req.DepartmentId; //r.EsId = req.EsId; //r.Size = "50"; //r.StartAt = "0"; //ListResponse<TimeSelfService> Times = _selfServiceService.ChildGetAll<TimeSelfService>(r); string rep_params = vals.Text; TimeAttendanceViewListRequest req = new TimeAttendanceViewListRequest(); req.paramString = rep_params; req.StartAt = e.Start.ToString(); req.Size = "30"; req.sortBy = "dayId"; ListResponse <TimeSelfService> Times = _selfServiceService.ChildGetAll <TimeSelfService>(req); if (!Times.Success) { Common.errorMessage(Times); return; } List <XMLDictionary> timeCodeList = ConstTimeVariationType.TimeCodeList(_systemService); int currentTimeCode; Times.Items.ForEach(x => { x.fullName = x.employeeName; x.statusString = FillApprovalStatus(x.status); if (Int32.TryParse(x.timeCode, out currentTimeCode)) { x.timeCodeString = timeCodeList.Where(y => y.key == Convert.ToInt32(x.timeCode)).Count() != 0 ? timeCodeList.Where(y => y.key == Convert.ToInt32(x.timeCode)).First().value : string.Empty; } if (string.IsNullOrEmpty(x.notes)) { x.notes = " "; } //if (x.status == 2 || x.status == -1) //{ // btnApprovals.Disabled = true; // btnReject.Disabled = true; //} //else //{ // btnApprovals.Disabled = false; // btnReject.Disabled = false; //} }); // TimeStore.DataSource = Times.Items.Where(x=>x.status==1).ToList<Time>(); ////List<ActiveLeave> leaves = new List<ActiveLeave>(); //leaves.Add(new ActiveLeave() { destination = "dc", employeeId = 8, employeeName = new Model.Employees.Profile.EmployeeName() { fullName = "vima" }, endDate = DateTime.Now.AddDays(10) }); TimeStore.DataSource = Times.Items; TimeStore.DataBind(); } catch (Exception exp) { X.Msg.Alert(Resources.Common.Error, exp.Message).Show(); } }
public void Timebatch(string index) { try { string approve = index; string rep_params = vals.Text; TimeAttendanceViewListRequest req = new TimeAttendanceViewListRequest(); req.paramString = rep_params; req.StartAt = "0"; req.Size = "1000"; req.sortBy = "dayId"; ListResponse <TimeSelfService> Times = _selfServiceService.ChildGetAll <TimeSelfService>(req); //DashboardTimeListRequest r = new DashboardTimeListRequest(); //r.dayId = ""; //r.employeeId = 0; //if (!string.IsNullOrEmpty(_systemService.SessionHelper.GetEmployeeId())) // r.approverId = Convert.ToInt32(_systemService.SessionHelper.GetEmployeeId()); //else //{ // TimeStore.DataSource = new List<Time>(); // TimeStore.DataBind(); // return; //} //r.timeCode = timeVariationType.GetTimeCode(); //r.shiftId = "0"; //r.apStatus = "1"; //r.BranchId = req.BranchId; //r.DivisionId = req.DivisionId; //r.PositionId = req.PositionId; //r.DepartmentId = req.DepartmentId; //r.EsId = req.EsId; //r.StartAt = "0"; //r.Size = "50"; //ListResponse<TimeSelfService> Times = _selfServiceService.ChildGetAll<TimeSelfService>(r); if (!Times.Success) { Common.errorMessage(Times); return; } PostRequest <TimeSelfService> request = new PostRequest <TimeSelfService>(); PostResponse <TimeSelfService> resp; Times.Items.ForEach(x => { if (x.status != 2 && x.status != -1) { request.entity = x; if (approve == "true") { request.entity.status = 2; } else { request.entity.status = -1; } resp = _selfServiceService.ChildAddOrUpdate <TimeSelfService>(request); if (!resp.Success) { Common.errorMessage(resp); throw new Exception(); } } }); TimeStore.Reload(); //TimeStore.RemoveAll(); } catch (Exception exp) { if (!string.IsNullOrEmpty(exp.Message)) { X.MessageBox.Alert(Resources.Common.Error, exp.Message).Show(); } } }
protected void Store1_RefreshData(object sender, StoreReadDataEventArgs e) { try { string rep_params = vals.Text; TimeAttendanceViewListRequest req = new TimeAttendanceViewListRequest(); req.paramString = rep_params; req.StartAt = filterStartAT.Text == "true"?"0": e.Start.ToString(); StartAt.Text = e.Start.ToString(); req.Size = "30"; req.sortBy = "dayId"; ListResponse <AttendanceDay> daysResponse; if (FromSelfService.Text == "true") { daysResponse = _selfServiceService.ChildGetAll <AttendanceDay>(req); } else { daysResponse = _timeAttendanceService.ChildGetAll <AttendanceDay>(req); } if (!daysResponse.Success) { Common.errorMessage(daysResponse); return; } bool rtl = _systemService.SessionHelper.CheckIfArabicSession(); List <TimeAttendanceCompositeObject> objs = new List <TimeAttendanceCompositeObject>(); int max = 0; string fsstring = ""; string asstring = ""; string tvstring = ""; CultureInfo c = new CultureInfo("en"); switch (_systemService.SessionHelper.getLangauge()) { case "ar": { c = new CultureInfo("en"); } break; case "en": { c = new CultureInfo("en"); } break; case "fr": { c = new CultureInfo("fr-FR"); } break; case "de": { c = new CultureInfo("de-DE"); } break; } Dictionary <String, string> parameter = Common.FetchParametersAsDictionary(rep_params); string timeCode = ""; if (parameter.ContainsKey("4")) { timeCode = parameter["4"].ToString(); } foreach (var x in daysResponse.Items) { max++; x.dayIdString = DateTime.ParseExact(x.dayId, "yyyyMMdd", new CultureInfo("en")).ToString(_systemService.SessionHelper.GetDateformat(), c); //ReportGenericRequest r = new ReportGenericRequest(); //r.paramString = "1| " + x.employeeId + "^2|" + x.dayId + "^3|" + x.dayId; //ListResponse<FlatSchedule> fsresponse = _timeAttendanceService.ChildGetAll<FlatSchedule>(r); //if (!fsresponse.Success) //{ // Common.errorMessage(fsresponse); // return; //} //fsresponse.Items.ForEach(fs => { fsstring += fs.from + " - " + fs.to + "|"; }); //if (fsstring.Length > 1) //{ // fsstring = fsstring.Substring(0, fsstring.Length - 1); // fsstring = "<span style='vertical-align:middle!important;'>" + fsstring + "</span>"; //} //AttendanceShiftListRequest asReq = new AttendanceShiftListRequest(); //asReq.EmployeeId = Convert.ToInt32(x.employeeId); //asReq.DayId = x.dayId; //ListResponse<AttendanceShift> asResp = _timeAttendanceService.ChildGetAll<AttendanceShift>(asReq); //if (!asResp.Success) //{ // Common.errorMessage(asResp); // return; //} //asResp.Items.ForEach(asItem => { asstring += asItem.checkIn + " - " + asItem.checkOut + "|"; }); //if (asstring.Length > 1) // asstring = asstring.Substring(0, asstring.Length - 1); ReportGenericRequest tvReq = new ReportGenericRequest(); if (string.IsNullOrEmpty(timeCode)) { tvReq.paramString = "1|" + x.employeeId + "^2|" + x.dayId + "^3|" + x.dayId + "&_startAt=0&_size=5000&_sortBy=date,employeeRef"; } else { tvReq.paramString = "1|" + x.employeeId + "^2|" + x.dayId + "^3|" + x.dayId + "^4|" + timeCode + "&_startAt=0&_size=5000&_sortBy=date,employeeRef"; } ListResponse <DashBoardTimeVariation> tvResp; if (FromSelfService.Text == "true") { tvResp = _selfServiceService.ChildGetAll <DashBoardTimeVariation>(tvReq); } else { tvResp = _timeAttendanceService.ChildGetAll <DashBoardTimeVariation>(tvReq); } if (!tvResp.Success) { Common.errorMessage(tvResp); return; } tvResp.Items.ForEach(tv => { string color = "black"; if (tv.apStatus.HasValue) { switch (tv.apStatus.Value) { case 1: color = "black"; break; case 2: color = "green"; break; case -1: color = "red"; break; } } string scriptCode = "App.direct.DisplayApprovals(\"" + x.dayId + "\",\"" + x.employeeId + "\",\"" + tv.shiftId + "\",\"" + tv.timeCode + "\");"; if (tv.timeCode == 20 || tv.timeCode == 41) { tvstring += "<span class='time-variation-link' style='color:" + color + "' onclick='" + scriptCode + "'>" + tv.timeName + "</span>" + "|"; } else { tvstring += "<span class='time-variation-link' style='color:" + color + "' onclick='" + scriptCode + "'>" + tv.timeName + " : " + tv.duration.ToString() + " " + minutesText.Text + "</span>" + "|"; } }); if (tvstring.Length > 1) { tvstring = tvstring.Substring(0, tvstring.Length - 1); } objs.Add(new TimeAttendanceCompositeObject() { FSString = fsstring, ASString = asstring, TVString = tvstring, dayId = x.dayId, branchName = x.branchName, departmentName = x.departmentName, employeeName = x.employeeName, employeeId = x.employeeId.ToString(), dayIdString = x.dayIdString, positionName = x.positionName, attendance = x.attendance, schedule = x.schedule, effectiveTime = x.effectiveTime }); if (max > 30) { break; } fsstring = ""; asstring = ""; tvstring = ""; } Store1.DataSource = objs; Store1.DataBind(); e.Total = daysResponse.count; } catch (Exception exp) { X.Msg.Alert(Resources.Common.Error, exp.Message).Show(); } }