Ejemplo n.º 1
0
        public void Processrecords(string index)

        {
            processUnscheduledPunch     PUP        = new processUnscheduledPunch();
            Dictionary <string, string> parameters = Common.FetchParametersAsDictionary(vals.Text);

            if (parameters.ContainsKey("1"))
            {
                PUP.startDate = DateTime.ParseExact(parameters["1"], "yyyyMMdd", new CultureInfo("en")).ToString("yyyy-MM-dd");
            }
            if (parameters.ContainsKey("2"))
            {
                PUP.endDate = DateTime.ParseExact(parameters["2"], "yyyyMMdd", new CultureInfo("en")).ToString("yyyy-MM-dd");
            }

            if (parameters.ContainsKey("4"))
            {
                PUP.branchId = parameters["4"];
            }
            if (parameters.ContainsKey("3"))
            {
                PUP.employeeId = parameters["3"];
            }

            PostRequest <processUnscheduledPunch> request = new PostRequest <processUnscheduledPunch>();

            request.entity = PUP;
            PostResponse <processUnscheduledPunch> r = _timeAttendanceService.ChildAddOrUpdate <processUnscheduledPunch>(request);

            if (!r.Success)//it maybe be another condition
            {
                //Show an error saving...
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                Common.errorMessage(r);
                return;
            }
            else
            {
                Notification.Show(new NotificationConfig
                {
                    Title = Resources.Common.Notification,
                    Icon  = Icon.Information,
                    Html  = Resources.Common.RecordSavingSucc
                });

                //  this.EditRecordWindow.Close();
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }