Beispiel #1
0
        protected void ProcessData(object sender, DirectEventArgs e)
        {
            try
            {
                LeaveImportingService service = null;
                service = new LeaveImportingService(new CSVImporter(CurrentPath.Text));
                List <LeaveRequest> shifts = service.ImportUnvalidated(CurrentPath.Text);

                File.Delete(CurrentPath.Text);



                DictionarySessionStorage storage = new DictionarySessionStorage();
                storage.Save("AccountId", _systemService.SessionHelper.Get("AccountId"));
                storage.Save("UserId", _systemService.SessionHelper.Get("UserId"));
                storage.Save("key", _systemService.SessionHelper.Get("Key"));
                SessionHelper   h   = new SessionHelper(storage, new APIKeyBasedTokenGenerator());
                EmployeeService emp = new EmployeeService(new EmployeeRepository(), h);

                ILeaveManagementService _timeAtt = new LeaveManagementService(h, new LeaveManagementRepository());
                SystemService           _system  = new SystemService(new SystemRepository(), h);
                LeaveBatchRunner        runner   = new LeaveBatchRunner(storage, _system, _timeAtt, emp)
                {
                    Items = shifts, OutputPath = MapPath("~/Imports/" + _systemService.SessionHelper.Get("AccountId") + "/")
                };
                runner.Process();
                this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", this.TaskManager1.ClientID);
            }
            catch (Exception exp)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation).Show();
                this.ResourceManager1.AddScript("{0}.stopTask('longactionprogress');", this.TaskManager1.ClientID);
            }
        }
Beispiel #2
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);
            }
        }