Exemplo n.º 1
0
        protected void ProcessData(object sender, DirectEventArgs e)
        {
            try
            {
                DepartmentImportingService service = null;
                service = new DepartmentImportingService(new CSVImporter(CurrentPath.Text));
                List <Department> 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());
                IEmployeeService         emp      = new EmployeeService(new EmployeeRepository(), h);
                ICompanyStructureService _timeAtt = new CompanyStructureService(new CompanyStructureRepository(), h);
                SystemService            _system  = new SystemService(new SystemRepository(), h);
                DepartmentBatchRunner    runner   = new DepartmentBatchRunner(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
            {
                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);
            }
        }
Exemplo n.º 2
0
        public ServicesTests()
        {
            var mapperConfig = new MapperConfiguration(
                opts => opts.CreateMap <EmployeeDTO, Employee>().ReverseMap());

            mapper = mapperConfig.CreateMapper();
            mockCompanyStructureRepository = CreateMockRepository();

            companyStructureService = new CompanyStructureService(mapper, mockCompanyStructureRepository.Object);
            employeeService         = new EmployeeService(mapper, mockCompanyStructureRepository.Object);
        }
Exemplo n.º 3
0
        protected void ProcessData(object sender, DirectEventArgs e)
        {
            try
            {
                PayCodeImportingService service = null;
                service = new PayCodeImportingService(new CSVImporter(CurrentPath.Text));
                List <PayCode> 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());
                IPayrollService          PS       = new PayrollService(new PayrollRepository(), h);
                ICompanyStructureService _timeAtt = new CompanyStructureService(new CompanyStructureRepository(), h);
                SystemService            _system  = new SystemService(new SystemRepository(), h);
                PayCodeBatchRunner       runner   = new PayCodeBatchRunner(storage, _system, _timeAtt, PS)
                {
                    Items = shifts, OutputPath = MapPath("~/Imports/" + _systemService.SessionHelper.Get("AccountId") + "/")
                };
                runner.Process();
                this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", this.TaskManager1.ClientID);
            }
            catch (Exception exp)
            {
                string[] errorDetails = exp.Source.Split(';');
                if (errorDetails.Length == 3)
                {
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br />" + Resources.Common.LineNO + errorDetails[2] + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + errorDetails[0] + " " + errorDetails[1] + "<br />" + GetGlobalResourceObject("Common", "ExceptionMessage") + exp.Message).Show();
                }
                else
                {
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br />" + Resources.Common.LineNO + errorDetails[1] + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + errorDetails[0] + "<br />" + GetGlobalResourceObject("Common", "ExceptionMessage") + exp.Message).Show();
                }
                //X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br /> " + Resources.Common.LineNO + exp.HelpLink + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + exp.Source + " " + exp.Message).Show();
                this.ResourceManager1.AddScript("{0}.stopTask('longactionprogress');", this.TaskManager1.ClientID);
                Viewport1.ActiveIndex = 0;
            }
        }