Пример #1
0
        private void LongAction(object state)
        {
            object[]      array    = state as object[];
            SessionHelper h        = (SessionHelper)array[0];
            int           activity = Convert.ToInt32(array[1]);



            _emp = new EmployeeService(new EmployeeRepository(), h);
            LoanTrackingService    _lt = new LoanTrackingService(new LoanTrackingRepository(), h);
            LeaveManagementService _lm = new LeaveManagementService(h, new LeaveManagementRepository());
            TimeAttendanceService  _ta = new TimeAttendanceService(h, new TimeAttendanceRepository());
            AssetManagementService _am = new AssetManagementService(new AssetManagementRepository(), h);

            _system = new SystemService(new SystemRepository(), h);
            _help   = new HelpFunctionService(new HelpFunctionRepository(), h);


            try
            {
                SyncActivity SA = new SyncActivity();
                SA.startDate = startingDate.SelectedDate;
                SA.endDate   = endingDate.SelectedDate;

                PostRequest <SyncActivity> req = new PostRequest <SyncActivity>();
                req.entity = SA;
                PostResponse <SyncActivity> resp = new PostResponse <SyncActivity>();

                switch (activity)
                {
                case 1:
                    resp = _ta.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 2:
                    resp = _lm.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 3:
                    resp = _lm.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 4:
                    resp = _lt.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 5:
                    resp = _emp.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 6:
                    resp = _am.ChildAddOrUpdate <SyncActivity>(req);
                    break;
                }


                if (!resp.Success)
                {
                    HttpRuntime.Cache.Insert("ErrorMsgSync", resp.Error);
                    HttpRuntime.Cache.Insert("LogIdMsgSync", resp.LogId);
                }



                HttpRuntime.Cache.Insert("syncAC_RecordId", resp.recordId);
            }

            catch (Exception exp)
            {
                HttpRuntime.Cache.Insert("ExceptionMsgSync", exp.Message);
            }
        }
Пример #2
0
        private void LongAction(object state)
        {
            object[]      array = state as object[];
            SessionHelper h     = (SessionHelper)array[0];



            //if (HttpRuntime.Cache["TotalRecords"] == null)
            //    HttpRuntime.Cache.Insert("TotalRecords",0);
            //if (HttpRuntime.Cache["LongActionProgress"] == null)
            //    HttpRuntime.Cache.Insert("LongActionProgress", 0);



            _time = new TimeAttendanceService(h, new TimeAttendanceRepository());


            try
            {
                GenerateAttendanceDay GD = new GenerateAttendanceDay();
                PostRequest <GenerateAttendanceDay> request = new PostRequest <GenerateAttendanceDay>();
                GD.employeeId = Convert.ToInt32(employeeFilter.Value);
                //GD.fromDayId = startingDate.SelectedDate.ToString("yyyyMMdd");
                //GD.toDayId = endingDate.SelectedDate.ToString("yyyyMMdd");
                //if (string.IsNullOrEmpty(branchId.Value.ToString()))
                //    GD.branchId = 0;
                //else
                //    GD.branchId = Convert.ToInt32(branchId.Value);

                request.entity = GD;


                PostResponse <GenerateAttendanceDay> resp = _time.ChildAddOrUpdate <GenerateAttendanceDay>(request);
                if (!resp.Success)
                { //Show an error saving...
                    if (resp.ErrorCode == "Error_1")
                    {
                        HttpRuntime.Cache.Insert("ErrorMsgGenAD", Resources.Errors.Error_1);
                        HttpRuntime.Cache.Insert("ErrorLogIdGenAD", " ");
                    }
                    else
                    {
                        HttpRuntime.Cache.Insert("ErrorMsgGenAD", resp.Error);
                        HttpRuntime.Cache.Insert("ErrorLogIdGenAD", resp.LogId);
                    }
                    //      HttpRuntime.Cache.Insert("ErrorErrorCodeGenAD", resp.ErrorCode);
                }
                else
                {
                    HttpRuntime.Cache.Insert("genFS_RecordId", resp.recordId);
                }



                //if (HttpRuntime.Cache["TotalRecords"] != null)
                //    HttpRuntime.Cache.Remove("TotalRecords");
                //HttpRuntime.Cache["TotalRecords"] = emps.count;
            }

            catch (Exception exp)
            {
                HttpRuntime.Cache.Insert("ErrorMsgGenAD", exp.Message);
            }
        }