Esempio n. 1
2
        static void Main(string[] args)
        {
            var connectionString = TestTaskConfiguration.Instance.ConnectionString;
            var context = new DataContext(connectionString);
            var repository = new EmployeeRepository(context);
            var service = new EmployeeService(repository);

            var node = new EmployeeReportModel();

            node.EmployeeDetails = service.All().OrderBy(x => x.FirstName).Select(x => new EmployeeReportDetailsModel
            {
                Name = x.FirstName,
                Wage = x.Wage
            }).ToList();

            dataList.Add(node);

            ReportViewer reportViewer = new ReportViewer();
            reportViewer.ProcessingMode = ProcessingMode.Local;
            reportViewer.LocalReport.ReportPath = AppDomain.CurrentDomain.BaseDirectory + @"\..\..\EmployeeReportTemplate.rdlc";
            reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(ReportViewer_OnSubreportProcessing);
            reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DSEmployee", dataList));

            Byte[] result = reportViewer.LocalReport.Render("PDF");

            using (FileStream fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + @"\Test.pdf", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write))
            {
                fs.Write(result, 0, result.Length);
                fs.Flush();
                fs.Close();
            }

            //Console.ReadKey();
        }
        public async Task CanCreateMonthlyAliases(DateTime utcNow) {
            SystemClock.SetFixedTime(utcNow);
            var index = new MonthlyEmployeeIndex(_configuration, 1);
            await index.DeleteAsync();
            
            using (new DisposableAction(() => index.DeleteAsync().GetAwaiter().GetResult())) {
                await index.ConfigureAsync();
                var repository = new EmployeeRepository(index.Employee);

                for (int i = 0; i < 4; i++) {
                    var employee = await repository.AddAsync(EmployeeGenerator.Generate(createdUtc: utcNow.SubtractMonths(i)));
                    Assert.NotNull(employee?.Id);

                    Assert.Equal(1, await index.GetCurrentVersionAsync());
                    var existsResponse = await _client.IndexExistsAsync(index.GetIndex(employee.CreatedUtc));
                    _logger.Trace(() => existsResponse.GetRequest());
                    Assert.True(existsResponse.IsValid);
                    Assert.True(existsResponse.Exists);

                    var aliasesResponse = await _client.GetAliasesAsync(a => a.Index(index.GetIndex(employee.CreatedUtc)));
                    _logger.Trace(() => aliasesResponse.GetRequest());
                    Assert.True(aliasesResponse.IsValid);
                    Assert.Equal(1, aliasesResponse.Indices.Count);

                    var aliases = aliasesResponse.Indices.Values.Single().Select(s => s.Name).ToList();
                    aliases.Sort();

                    Assert.Equal(GetExpectedEmployeeMonthlyAliases(index, utcNow, employee.CreatedUtc), String.Join(", ", aliases));
                }
            }
        }
 public void Setup()
 {
     configuration = Substitute.For<IConfiguration>();
     activeDirectoryService = Substitute.For<IActiveDirectoryService>();
     principalMapper = Substitute.For<IMapper<IPrincipal, Employee>>();
     sut = new EmployeeRepository(activeDirectoryService, configuration, principalMapper);
 }
 public ManageEmployeeDetails()
 {
     InitializeComponent();
     empRepo = new EmployeeRepository();
     roleRepo = new RoleRepository();
     HideControls(false);
 }
Esempio n. 5
0
 public void DeleteEmployee(string employeeId)
 {
     //unitOfWork.StartTransaction();
     EmployeeRepository repo = new EmployeeRepository(unitOfWork);
     repo.Delete(x => x.EmployeeId == employeeId);
     //unitOfWork.Commit();
 }
 public TimeClockUnitOfWork(TimeClockContext context)
 {
     _context = context;
     Employees = new EmployeeRepository(_context);
     Shifts = new ShiftRepository(_context);
     IncompleteShifts = new IncompleteShiftRepository(_context);
 }
        public void ShouldDeleteEmployee()
        {
            // Arrange
            using (IEmployeeContext employeeContext = new EmployeeContext(new DropCreateDatabaseAlways<EmployeeContext>()))
            {
                IEmployeeRepository employeeRepository = new EmployeeRepository(employeeContext);
                var employee1 = CreateEntity.Employee1;
                var employee2 = CreateEntity.Employee2;

                employeeRepository.Add(employee1);
                employeeRepository.Add(employee2);
                var numberOfAdds = +employeeContext.SaveChanges();

                // Act
                employeeRepository.Remove(employee2);
                var numberOfDeletes =+ employeeContext.SaveChanges();

                // Assert
                numberOfAdds.Should().Be(2);
                numberOfDeletes.Should().Be(1);

                var allEmployees = employeeRepository.GetAll().ToList();
                allEmployees.Should().HaveCount(1);
                allEmployees.ElementAt(0).ShouldBeEquivalentTo(employee1, options => options.IncludingAllDeclaredProperties());
            }
        }
        public void Import_Logic_With_One_Employee_Correctly() {
            List<Employee> employees = new List<Employee>();
            Employee emp1 = new Employee() {Id = 1000000, FirstName = "TestOneEmp", LastName = "Peterson", BirthDate = DateTime.Now.AddYears(-96), Address = "Højvej 22", ZipCode = 6700, City = "Esbjerg", Country = "Danmark", Phone = "56428657", Active = true, Rank = "Programmer" };
            employees.Add(emp1);

            ImportExportLogic imEx = new ImportExportLogic();
            var principal = new GenericPrincipal(new GenericIdentity("*****@*****.**"), null);
            Thread.CurrentPrincipal = principal;
            var response = imEx.Import(employees);
            Assert.IsTrue(response);
            CompanyRepository comprepo = new CompanyRepository();
            Company comp = comprepo.Get("*****@*****.**");
            EmployeeRepository emprepo = new EmployeeRepository();
            IEnumerable<Employee> emps = emprepo.GetAll();
            Employee emp = emps.FirstOrDefault(c => c.FirstName.Equals("TestOneEmp"));
            Assert.AreEqual(comp.Identity.Email, emp.Company.Identity.Email);
            LogRepository logrepo = new LogRepository();
            IEnumerable<Log> logList = logrepo.GetAll();

            bool containsEmp = false;
            foreach (var log in logList)
            {
                foreach (var logEmp in log.Employees)
                {
                    if (logEmp.FirstName.Equals(emp.FirstName) && log.Import)
                    {
                        containsEmp = true;
                    }
                }
            }

            Assert.IsTrue(containsEmp);

        }
Esempio n. 9
0
        static void GenerateEmployees()
        {
            var connectionString = TestTaskConfiguration.Instance.ConnectionString;
            var context = new DataContext(connectionString);
            var repository = new EmployeeRepository(context);
            var service = new EmployeeService(repository);

            var wageRandom = new Random();
            var positionRandom = new Random();

            for (var i = 0; i < 100; i++)
            {
                var employee = new Employee
                {
                    FirstName = GenerateAnRandomString(),
                    Wage = wageRandom.Next(100, 100000),
                    Position = GenerateAnRandomString(),
                    Status = (EmployeeStatus)positionRandom.Next(1, 2),
                    CreatedDate = DateTime.UtcNow,
                    ModifiedDate = DateTime.UtcNow
                };

                service.Create(employee);

                Console.WriteLine($"{i} employee was added into DB");
            }
        }
Esempio n. 10
0
 public void TestGetWithId()
 {
     var repo = new EmployeeRepository();
     var empController = new EmployeeController(repo);
     var employee = empController.Get(1);
     Assert.AreEqual("1 : Mike", employee);
 }
        public void Should_Not_Mark_As_Delete_Twice()
        {
            //Arrange
            const string employeeName = "Funcionario-Test";
            var employee = new Employee
            {
                Name = employeeName,
                LastName = "Testeee"
            };

            var employeeRepository = new EmployeeRepository(_uow);
            employeeRepository.Add(employee);
            _uow.Save();

            var employeeExpected = employeeRepository.GetEmployeeByName(employee.Name);

            //Act
            employeeRepository.Remove(employeeExpected.Id);
            _uow.Save();

            employeeRepository.Remove(employeeExpected.Id);
            _uow.Save();

            //Assert
            Assert.IsNotNull(employeeExpected);
            Assert.IsTrue(employeeExpected.IsDeleted);
            Assert.AreEqual(employeeName + " (Excluido)", employeeExpected.Name);

            employeeRepository.DeleteEntityPermanently(employeeExpected);
            _uow.Save();

            Assert.IsNull(employeeRepository.GetEmployeeByName(employee.Name));
        }
 public ServiceReportOperatorWise()
 {
     InitializeComponent();
     oEmployee = new EmployeeRepository();
     oDonorRepo = new DonorRepository();
     lstEmployee = oEmployee.GetAllAsQuerable().ToList();
 }
        public void ShouldAddDepartment()
        {
            // Arrange
            using (IEmployeeContext employeeContext = new EmployeeContext())
            {
                IEmployeeRepository employeeRepository = new EmployeeRepository(employeeContext);
                employeeRepository.Add(CreateEntity.Employee1);
                employeeRepository.Add(CreateEntity.Employee2);
                employeeRepository.Add(CreateEntity.Employee3);
                employeeContext.SaveChanges();

                IDepartmentRepository departmentRepository = new DepartmentRepository(employeeContext);
                var department = CreateEntity.Department1;

                // Act
                departmentRepository.Add(department);
                var numberOfChangesCommitted = employeeContext.SaveChanges();

                // Assert
                numberOfChangesCommitted.Should().BeGreaterThan(0);

                var allDepartments = departmentRepository.GetAll().ToList();
                allDepartments.Should().HaveCount(1);
                allDepartments.ElementAt(0).ShouldBeEquivalentTo(department, options => options.IncludingAllDeclaredProperties());
            }
        }
        public ReadOnlyRepositoryTests(ITestOutputHelper output) : base(output) {
            _identityRepository = new IdentityRepository(_configuration);
            _dailyRepository = new DailyLogEventRepository(_configuration);
            _employeeRepository = new EmployeeRepository(_configuration);

            RemoveDataAsync().GetAwaiter().GetResult();
        }
Esempio n. 15
0
        public ActionResult Edit(int id)
        {
            Employee e = new EmployeeRepository().GetById(id);

            e.DepartmentList = new DepartmentRepository().GetAll();
            return View(e);
        }
        public DashboardViewModel()
        {
            _departmentRepository = new DepartmentRepository();
            _employeeRepository = new EmployeeRepository();
            _projectRepository = new ProjectRepository();

            RefreshAll();
        }
        public void GetEmployeeWithIdTest()
        {
            var repo = new EmployeeRepository();
            var empController = new EmployeeController(repo);
            var value = empController.Employee(1);

            Assert.AreEqual("1 : Mike", value);
        }
 private DataProvider()
 {
     Companies = new CompanyRepository();
     Addresses = new AddressRepository();
     Accounts = new AccountRepsitory();
     Employees = new EmployeeRepository();
     Transactions = new TransactionRepository();
 }
        public void AddEmployee()
        {
            var ctx = new CompanyCtx();

            var employeeRepo = new EmployeeRepository(ctx);
            var e1 = new Employee { EmployeeCode = "E88", FirstName = "Jonelle", LastName = "Castaneda",DepartmentCode="D01" };
            employeeRepo.Add(e1);
        }
        public EmployeeProjectListViewModel(Employee employee)
        {
            _repository = new EmployeeRepository();
            _employee = employee;

            AddProjectCommand = new Command(AddProject);
            DeleteProjectCommand = new Command<ProjectInvolement>(x => x != null, DeleteProject);
        }
Esempio n. 21
0
        public EmployeeRepositoryTests() {
            _queryBuilder.RegisterDefaults();
            _queryBuilder.Register(new AgeQueryBuilder());

            _configuration = new ElasticConfiguration(_workItemQueue, _cache);
            _client = _configuration.GetClient(new[] { new Uri(ConfigurationManager.ConnectionStrings["ElasticConnectionString"].ConnectionString) });
            _repository = new EmployeeRepository(new ElasticRepositoryContext<Employee>(_cache, _client, _configuration, null, null, _queryBuilder));
            _repositoryWithDateBasedIndex = new EmployeeWithDateBasedIndexRepository(new ElasticRepositoryContext<EmployeeWithDate>(_cache, _client, _configuration, null, null, _queryBuilder), _employeeWithDateIndex);
        }
        public NewEmployeeViewModel()
        {
            _repository = new EmployeeRepository();
            Employee = new Employee();
            MainProperties = new EmployeeMainPropertiesViewModel(Employee);

            OkCommand = new Command(() => MainProperties.IsValid(), Save);
            CancelCommand = new Command(() => DialogResult = false);
        }
        public EmployeeListViewModel()
        {
            _repository = new EmployeeRepository();
            RefreshAll();

            AddEmployeeCommand = new Command(AddEmployee);
            EditEmployeeCommand = new Command<EmployeeDto>(x => x != null, EditEmployee);
            DeleteEmployeeCommand = new Command<EmployeeDto>(x => x != null, DeleteEmployee);
        }
        public DepartmentViewModel(Department department)
        {
            _repository = new DepartmentRepository();
            PossiblesHeads = new EmployeeRepository().GetPossiblesHeads(department.Head);
            Department = department;

            OkCommand = new Command(() => !string.IsNullOrWhiteSpace(Name), Save);
            CancelCommand = new Command(() => DialogResult = false);
        }
Esempio n. 25
0
 public AptekaNetUnitOfWork()
 {
     Context = new AptekaNETDbContext();
     OrderRepository = new OrderRepository(Context);
     EmployeeRepository = new EmployeeRepository(Context);
     CustomerRepository = new CustomerRepository(Context);
     MedicineRepository = new MedicineRepository(Context);
     ProductRepository = new ProductRepository(Context);
     PharmacyRepository = new PharmacyRepository(Context);
 }
 public OperationResult ChangeEmployee(Model.Employee model)
 {
     using (IUnitOfWork unitofwork = new EntityFrameworkContext())
     {
         IEmployeeRepository employeeRepository = new EmployeeRepository(unitofwork);
         var employee = employeeRepository.GetEntity.Where(m => m.UserName == model.UserName || m.Email == model.Email).FirstOrDefault();
         employee.RealName = model.RealName;
         employeeRepository.Update(employee);
         int count = unitofwork.Commit();
         return new OperationResult(OperationResultType.Success, count.ToString());
     }
 }
Esempio n. 27
0
 public List<EmployeeModel> GetAllEmployees()
 {
     //unitOfWork.StartTransaction();
     EmployeeRepository repo = new EmployeeRepository(unitOfWork);
     List<EmployeeModel> employeeList = new List<EmployeeModel>();
     List<Employee> employee = new List<Employee>();
     AutoMapper.Mapper.Map(employeeList, employee);
     employee = repo.GetAll().ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(employee, employeeList);
     return employeeList;
 }
        public void Given_task_exists()
        {
            var russellWilliamsEmployeeId = Guid.Parse("D2122FFF-1DCD-4A3C-83AE-E3503B394EB4");
            var employee = new EmployeeRepository(ObjectFactory.GetInstance<IBusinessSafeSessionManager>()).GetById(russellWilliamsEmployeeId);

            var target = new TaskListRepository(ObjectFactory.GetInstance<IBusinessSafeSessionManager>(), ObjectFactory.GetInstance<IBusinessSafeSessionManagerFactory>());

            List<long> siteIds = employee.User.Site.GetThisAndAllDescendants().Select(x => x.Id).ToList();
            var result = target.Search(55881, new List<Guid>(){russellWilliamsEmployeeId}, false, siteIds);

            ObjectFactory.GetInstance<IBusinessSafeSessionManager>().CloseSession();
        }
Esempio n. 29
0
 public List<EmployeeModel> GetEmployeeInfoListByEmployeeIds(string[] employeeIds)
 {
     //unitOfWork.StartTransaction();
     EmployeeRepository repoEmployee = new EmployeeRepository(unitOfWork);
     List<EmployeeModel> employeeModel = new List<EmployeeModel>();
     List<Employee> employee = new List<Employee>();
     employee = repoEmployee.GetAll().Where(x => employeeIds.Contains(x.EmployeeId.ToString())).ToList();
     //unitOfWork.Commit();
     //rating = repo.GetAll().Where(x => x.JobId == JobId).ToList();
     AutoMapper.Mapper.Map(employee, employeeModel);
     return employeeModel;
 }
Esempio n. 30
0
 public EmployeeModel GetEmployeeById(string employeeId)
 {
     //unitOfWork.StartTransaction();
     EmployeeRepository repo = new EmployeeRepository(unitOfWork);
     EmployeeModel employeeModel = new EmployeeModel();
     Employee employee = new Employee();
     AutoMapper.Mapper.Map(employeeModel, employee);
     Dispose(true);
     employee = repo.GetAll().Where(x => x.EmployeeId == employeeId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(employee, employeeModel);
     return employeeModel;
 }
Esempio n. 31
0
 public YearToDateService(EmployeeRepository employeeRepository)
 {
     _employeeRepository = employeeRepository;
 }
Esempio n. 32
0
 public EmployeeController()
 {
     _dbContext          = new MongoContext();
     _employeeRepository = new EmployeeRepository();
 }
Esempio n. 33
0
 public StatisticsService(EmployeeRepository employeeRepository)
 {
     _employeeRepository = employeeRepository;
 }
Esempio n. 34
0
        public void Dispatch(string connectionId, Model.ProgressState ps, CancellationToken cancellationToken, string workDispatchId, string userName)
        {
            Locker.LockKey = workDispatchId;
            ConnectionId   = connectionId;
            ps.State       = StateType.Start;
            NotifyConnection(ps.Clone());

            IQueryable <SortOrderDispatch> sortOrderDispatchQuery = SortOrderDispatchRepository.GetQueryable();
            IQueryable <SortOrder>         sortOrderQuery         = SortOrderRepository.GetQueryable();
            IQueryable <SortOrderDetail>   sortOrderDetailQuery   = SortOrderDetailRepository.GetQueryable();

            IQueryable <OutBillMaster>  outBillMasterQuery  = OutBillMasterRepository.GetQueryable();
            IQueryable <OutBillDetail>  outBillDetailQuery  = OutBillDetailRepository.GetQueryable();
            IQueryable <MoveBillMaster> moveBillMasterQuery = MoveBillMasterRepository.GetQueryable();
            IQueryable <MoveBillDetail> moveBillDetailQuery = MoveBillDetailRepository.GetQueryable();

            IQueryable <SortingLowerlimit> sortingLowerlimitQuery = SortingLowerlimitRepository.GetQueryable();
            IQueryable <SortingLine>       sortingLineQuery       = SortingLineRepository.GetQueryable();
            IQueryable <Storage>           storageQuery           = StorageRepository.GetQueryable();

            IQueryable <SortWorkDispatch> sortWorkDispatchQuery = SortWorkDispatchRepository.GetQueryable();

            workDispatchId = workDispatchId.Substring(0, workDispatchId.Length - 1);
            int[] work = workDispatchId.Split(',').Select(s => Convert.ToInt32(s)).ToArray();

            //调度表未作业的数据
            var temp = sortOrderDispatchQuery.Where(s => work.Any(w => w == s.ID) && s.WorkStatus == "1")
                       .Join(sortOrderQuery,
                             dp => new { dp.OrderDate, dp.DeliverLineCode },
                             om => new { om.OrderDate, om.DeliverLineCode },
                             (dp, om) => new { dp.OrderDate, dp.SortingLine, dp.DeliverLineCode, om.OrderID }
                             ).Join(sortOrderDetailQuery,
                                    dm => new { dm.OrderID },
                                    od => new { od.OrderID },
                                    (dm, od) => new { dm.OrderDate, dm.SortingLine, od.Product, od.UnitCode, od.Price, od.RealQuantity }
                                    ).GroupBy(r => new { r.OrderDate, r.SortingLine, r.Product, r.UnitCode, r.Price })
                       .Select(r => new { r.Key.OrderDate, r.Key.SortingLine, r.Key.Product, r.Key.UnitCode, r.Key.Price, SumQuantity = r.Sum(p => p.RealQuantity * r.Key.Product.UnitList.Unit02.Count) })
                       .GroupBy(r => new { r.OrderDate, r.SortingLine })
                       .Select(r => new { r.Key.OrderDate, r.Key.SortingLine, Products = r })
                       .ToArray();

            var    employee        = EmployeeRepository.GetQueryable().FirstOrDefault(i => i.UserName == userName);
            string operatePersonID = employee != null?employee.ID.ToString() : "";

            if (employee == null)
            {
                ps.State = StateType.Error;
                ps.Errors.Add("未找到当前用户,或当前用户不可用!");
                NotifyConnection(ps.Clone());
                return;
            }

            decimal sumAllotQuantity     = 0;
            decimal sumAllotLineQuantity = 0;

            MoveBillMaster lastMoveBillMaster = null;

            foreach (var item in temp)
            {
                try
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    bool hasError = false;
                    ps.State = StateType.Info;
                    ps.Messages.Add("开始调度" + item.SortingLine.SortingLineName);
                    NotifyConnection(ps.Clone());

                    using (var scope = new TransactionScope())
                    {
                        if (item.Products.Count() > 0)
                        {
                            if (cancellationToken.IsCancellationRequested)
                            {
                                return;
                            }

                            if (lastMoveBillMaster != null && lastMoveBillMaster.WarehouseCode != item.SortingLine.Cell.WarehouseCode)
                            {
                                if (MoveBillCreater.CheckIsNeedSyncMoveBill(lastMoveBillMaster.WarehouseCode))
                                {
                                    MoveBillCreater.CreateSyncMoveBillDetail(lastMoveBillMaster);
                                }
                            }

                            sumAllotLineQuantity = 0;

                            if (cancellationToken.IsCancellationRequested)
                            {
                                return;
                            }
                            MoveBillMaster moveBillMaster = MoveBillCreater.CreateMoveBillMaster(item.SortingLine.Cell.WarehouseCode,
                                                                                                 item.SortingLine.MoveBillTypeCode,
                                                                                                 operatePersonID);
                            moveBillMaster.Origin      = "2";
                            moveBillMaster.Description = "分拣调度生成!";
                            lastMoveBillMaster         = moveBillMaster;
                            foreach (var product in item.Products.ToArray())
                            {
                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }

                                decimal sumBillQuantity = temp.Sum(t => t.Products.Sum(p => p.SumQuantity));
                                sumAllotQuantity += product.SumQuantity;

                                decimal sumBillProductQuantity = item.Products.Sum(p => p.SumQuantity);
                                sumAllotLineQuantity += product.SumQuantity;

                                ps.State                = StateType.Processing;
                                ps.TotalProgressName    = "分拣作业调度";
                                ps.TotalProgressValue   = (int)(sumAllotQuantity / sumBillQuantity * 100);
                                ps.CurrentProgressName  = "正在调度:" + item.SortingLine.SortingLineName;
                                ps.CurrentProgressValue = (int)(sumAllotLineQuantity / sumBillProductQuantity * 100);
                                NotifyConnection(ps.Clone());

                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                //获取分拣线下限数据
                                var sortingLowerlimitQuantity = sortingLowerlimitQuery.Where(s => s.ProductCode == product.Product.ProductCode &&
                                                                                             s.SortingLineCode == product.SortingLine.SortingLineCode);
                                decimal lowerlimitQuantity = 0;
                                if (sortingLowerlimitQuantity.Count() > 0)
                                {
                                    lowerlimitQuantity = sortingLowerlimitQuantity.Sum(s => s.Quantity);
                                }

                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                //获取分拣备货区库存
                                var storageQuantity = storageQuery.Where(s => s.ProductCode == product.Product.ProductCode)
                                                      .Join(sortingLineQuery,
                                                            s => s.Cell,
                                                            l => l.Cell,
                                                            (s, l) => new { l.SortingLineCode, s.Quantity }
                                                            )
                                                      .Where(r => r.SortingLineCode == product.SortingLine.SortingLineCode);
                                decimal storQuantity = 0;
                                if (storageQuantity.Count() > 0)
                                {
                                    storQuantity = storageQuantity.Sum(s => s.Quantity);
                                }

                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }

                                //获取移库量(按整件计)
                                decimal quantity = 0;

                                if (lowerlimitQuantity == 0)
                                {
                                    quantity = product.SumQuantity - storQuantity;
                                }
                                else
                                {
                                    quantity = Math.Ceiling((product.SumQuantity + lowerlimitQuantity - storQuantity) / product.Product.Unit.Count)
                                               * product.Product.Unit.Count;
                                }

                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                AlltoMoveBill(moveBillMaster, product.Product, item.SortingLine.Cell, ref quantity, cancellationToken);

                                if (quantity > 0)
                                {
                                    //生成移库不完整,可能是库存不足;
                                    hasError = true;
                                    ps.State = StateType.Error;
                                    ps.Errors.Add(product.Product.ProductCode + " " + product.Product.ProductName + " 库存不足!");
                                    NotifyConnection(ps.Clone());
                                }
                            }

                            if (!hasError)
                            {
                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }

                                OutBillMaster outBillMaster = OutBillCreater.CreateOutBillMaster(item.SortingLine.Cell.WarehouseCode,
                                                                                                 item.SortingLine.OutBillTypeCode,
                                                                                                 operatePersonID);
                                outBillMaster.Origin      = "2";
                                outBillMaster.Description = "分拣调度生成!";
                                //添加出库单细单
                                foreach (var product in item.Products.ToArray())
                                {
                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    OutBillCreater.AddToOutBillDetail(outBillMaster, product.Product, product.Price, product.SumQuantity);
                                }

                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                //添加出库、移库主单和作业调度表
                                SortWorkDispatch sortWorkDisp = AddSortWorkDispMaster(moveBillMaster, outBillMaster, item.SortingLine.SortingLineCode, item.OrderDate);

                                //修改线路调度作业状态和作业ID
                                var sortDispTemp = sortOrderDispatchQuery.Where(s => work.Any(w => w == s.ID) &&
                                                                                s.OrderDate == item.OrderDate &&
                                                                                s.SortingLineCode == item.SortingLine.SortingLineCode);

                                foreach (var sortDisp in sortDispTemp.ToArray())
                                {
                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    sortDisp.SortWorkDispatchID = sortWorkDisp.ID;
                                    sortDisp.WorkStatus         = "2";
                                }
                                if (cancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                SortWorkDispatchRepository.SaveChanges();
                                scope.Complete();
                                ps.Messages.Add(item.SortingLine.SortingLineName + " 调度成功!");
                            }
                            else
                            {
                                ps.State = StateType.Info;
                                ps.Messages.Add(item.SortingLine.SortingLineName + " 调度失败!");
                                NotifyConnection(ps.Clone());
                                return;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    ps.State = StateType.Info;
                    ps.Errors.Add(item.SortingLine.SortingLineName + "作业调度失败! 详情:" + e.Message);
                    NotifyConnection(ps.Clone());
                    return;
                }
            }

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }
            if (MoveBillCreater.CheckIsNeedSyncMoveBill(lastMoveBillMaster.WarehouseCode))
            {
                MoveBillCreater.CreateSyncMoveBillDetail(lastMoveBillMaster);
            }
            MoveBillMasterRepository.SaveChanges();

            ps.State = StateType.Info;
            ps.Messages.Add("调度完成!");
            NotifyConnection(ps.Clone());
        }
 public EmployeeService()
 {
     ModelMapper.Configure();
     _employeeRepository = EmployeeRepository.Instance();
 }
        public ActionResult Unique(string field)
        {
            var result = EmployeeRepository.AllComplete().Distinct(new EmployeeComparer(field));

            return(this.Jsonp(result));
        }
Esempio n. 37
0
 public UnitOfWork(OrganizationsDbContext context)
 {
     _context  = context;
     Companies = new CompanyRepository(_context);
     Employees = new EmployeeRepository(_context);
 }
Esempio n. 38
0
 public SDICoreDemo()
 {
     Employees   = new EmployeeRepository(_context);
     Departments = new DepartmentRepository(_context);
 }
        public static IEnumerable <IEntitySubdivisionForUserPermissionValidationResult> Validate(IUnitOfWork uow, int userId, Type[] entityTypes)
        {
            var result = new List <EntitySubdivisionForUserPermissionValidationResult>();

            string[]    entityNames     = entityTypes.Select(x => x.Name).ToArray();
            var         employee        = EmployeeRepository.GetEmployeesForUser(uow, userId).FirstOrDefault();
            Subdivision mainSubdivision = employee == null ? null : employee.Subdivision;

            if (mainSubdivision != null)
            {
                var mainTypesName      = mainSubdivision.DocumentTypes.Select(x => x.Type);
                var mainAvailableTypes = entityTypes.Where(x => mainTypesName.Contains(x.Name));
                if (mainAvailableTypes.Any())
                {
                    EntitySubdivisionForUserPermissionValidationResult mainResultItem = new EntitySubdivisionForUserPermissionValidationResult(mainSubdivision, true);
                    foreach (var mainAvailableType in mainAvailableTypes)
                    {
                        var mainPermission = ServicesConfig.CommonServices.PermissionService.ValidateUserPermission(mainAvailableType, userId);
                        mainResultItem.AddPermission(
                            mainAvailableType,
                            new EntityPermission(
                                mainPermission.CanCreate,
                                mainPermission.CanRead,
                                mainPermission.CanUpdate,
                                mainPermission.CanDelete
                                )
                            );
                    }
                    result.Add(mainResultItem);
                }
            }

            var subdivisionsForEntities = SubdivisionsRepository.GetSubdivisionsForDocumentTypes(uow, entityTypes);
            var specialPermissions      = PermissionRepository.GetAllSubdivisionForUserEntityPermissionForSomeEntities(uow, userId, entityNames)
                                          .Where(x => subdivisionsForEntities.Contains(x.Subdivision) || Subdivision.ReferenceEquals(x.Subdivision, mainSubdivision));

            foreach (var entityType in entityTypes)
            {
                var mainPermission = ServicesConfig.CommonServices.PermissionService.ValidateUserPermission(entityType, userId);
                foreach (var permissionitem in specialPermissions.Where(x => x.TypeOfEntity.Type == entityType.Name))
                {
                    EntitySubdivisionForUserPermissionValidationResult resultItem = result.FirstOrDefault(x => x.Subdivision == permissionitem.Subdivision);
                    if (resultItem == null)
                    {
                        var isMainSubdivision = permissionitem.Subdivision != null && mainSubdivision != null && permissionitem.Subdivision.Id == mainSubdivision.Id;
                        resultItem = new EntitySubdivisionForUserPermissionValidationResult(permissionitem.Subdivision, isMainSubdivision);
                        result.Add(resultItem);
                    }
                    resultItem.AddPermission(
                        entityType,
                        new EntityPermission(
                            mainPermission.CanCreate && permissionitem.CanCreate,
                            mainPermission.CanRead && permissionitem.CanRead,
                            mainPermission.CanUpdate && permissionitem.CanUpdate,
                            mainPermission.CanDelete && permissionitem.CanDelete
                            )
                        );
                }
            }

            return(result);
        }
Esempio n. 40
0
 public EmployeeService(UnitOfWork unitOfWork)
 {
     db = unitOfWork.EmployeeRepository;
 }
Esempio n. 41
0
 public TestPayer(EmployeeRepository employeeRepository, PaymentDispatcherFactory paymentDispatcher) : base(employeeRepository, paymentDispatcher)
 {
 }
Esempio n. 42
0
 public EmployeeController(AppDbContext context)
 {
     EmployeeRepository = new EmployeeRepository(context);
     CompanyRepository  = new CompanyRepository(context);
 }
Esempio n. 43
0
 public Login()
 {
     InitializeComponent();
     empRepo = new EmployeeRepository();
 }
Esempio n. 44
0
 public string getEvents()
 {
     employeeRepository = new EmployeeRepository();
     return(employeeRepository.getEvents());
 }
Esempio n. 45
0
 public void TearDown()
 {
     repo = null;
 }
Esempio n. 46
0
 public EmployeeRepositoryTests()
 {
     db = new ReleaseTasksAPIContext();
     db.Database.BeginTransaction();
     underTest = new EmployeeRepository(db);
 }
Esempio n. 47
0
 public ActionResult Delete(int id)
 {
     EmployeeRepository.Delete(id);
     return(RedirectToAction("List"));
 }
Esempio n. 48
0
        public EmployeeFunctionsTests()
        {
            var employeeRepository = new EmployeeRepository();

            employees = employeeRepository.Employees;
        }
Esempio n. 49
0
 public EmployeeLogic(IEmployeeContext context, IMapper mapper)
 {
     Repository = new EmployeeRepository(context);
     _mapper    = mapper;
 }
 public EmployeesController(EmployeeRepository repo)
 {
     _repo = repo;
 }
Esempio n. 51
0
        private void ChangeTableData()
        {
            Employee emp = yentryEmployee.Subject as Employee;

            if (emp == null)
            {
                return;
            }

            employeeName = emp.ShortName;
            OnTabNameChanged();

            int month = (int)yenumcomboMonth.SelectedItem;
            int year  = yspinYear.ValueAsInt;

            logger.Debug(string.Format("Изменена дата на {0}.{1}", month, year));
            IList <EmployeeWorkChart> charts = null;

            var exist = newCharts.FirstOrDefault(e => e.Date.Month == month && e.Date.Year == year &&
                                                 e.Employee == emp);

            if (exist == null)
            {
                exist = loadedCharts.FirstOrDefault(e => e.Date.Month == month && e.Date.Year == year &&
                                                    e.Employee.Id == emp.Id);
                if (exist == null)
                {
                    logger.Debug("Загрузка данных из БД");

                    charts = EmployeeRepository.GetWorkChartForEmployeeByDate(
                        uow, emp, new DateTime(year, month, 1));

                    foreach (var item in charts)
                    {
                        if (!loadedCharts.Contains(item))
                        {
                            loadedCharts.Add(item);
                        }
                    }
                }
                else
                {
                    var tuple = cleared.FirstOrDefault(c => c.Item2.Month == month && c.Item2.Year == year &&
                                                       c.Item1 == emp.Id);
                    if (tuple == null)
                    {
                        logger.Debug("Получение данных из кеша");

                        charts = loadedCharts.Where(e => e.Date.Month == month && e.Date.Year == year &&
                                                    e.Employee == emp).ToList();
                    }
                }
            }
            else
            {
                logger.Debug("Получение измененных пользователем данных");

                charts = newCharts.Where(e => e.Date.Month == month && e.Date.Year == year &&
                                         e.Employee.Id == emp.Id).ToList();
            }

            var chartsFromTable = workcharttable.GetWorkChart();

            if (chartsFromTable.Count == 0)
            {
                if (loadedCharts.FirstOrDefault(c => c.Date.Month == workcharttable.Date.Month &&
                                                c.Date.Year == workcharttable.Date.Year &&
                                                c.Employee.Id == previousEmployee.Id) != null)
                {
                    cleared.Add(new Tuple <int, DateTime>(previousEmployee.Id,
                                                          new DateTime(workcharttable.Date.Year, workcharttable.Date.Month, 1)));
                }
            }

            SetEmployeeForCharts(chartsFromTable, previousEmployee);
            DeleteItemsByDate(newCharts, workcharttable.Date.Month, workcharttable.Date.Year, emp);
            newCharts.AddRange(chartsFromTable);

            logger.Debug("Передача данных в таблицу");
            workcharttable.SetWorkChart(charts);
            SetTableDate();
            previousEmployee = emp;
        }
Esempio n. 52
0
 public StrengthsController()
 {
     _context   = new KEPT_DBEntities();
     _employee  = new EmployeeRepository(_context);
     _strengths = new StrengthsRepository(_context);
 }
Esempio n. 53
0
 public HomeController()
 {
     repository = new EmployeeRepository();
 }
 public EmployeeController(EmployeeRepository empRepository, DepartamentRepository repository)
 {
     this._empRepository         = empRepository;
     this._departamentRepository = repository;
 }
Esempio n. 55
0
 public EmployeeService(string username, string password)
 {
     employeeRepository = new EmployeeRepository(username, password);
 }
Esempio n. 56
0
 public string getThaughtsFortheDay()
 {
     employeeRepository = new EmployeeRepository();
     return(employeeRepository.getThaughts());
 }
Esempio n. 57
0
        public EmployeesViewModel()
        {
            EmployeeRepository employeeRepository = new EmployeeRepository();

            Employees = employeeRepository.GetEmployees();
        }
Esempio n. 58
0
 public EmployeeController()
 {
     EmployeeRepository = new EmployeeRepository();
 }
Esempio n. 59
0
        public bool AllotConfirm(string billNo, string userName, ref string errorInfo)
        {
            try
            {
                var ibm      = OutBillMasterRepository.GetQueryable().FirstOrDefault(i => i.BillNo == billNo && i.Status == "3");
                var employee = EmployeeRepository.GetQueryable().FirstOrDefault(i => i.UserName == userName);

                if (employee == null)
                {
                    errorInfo = "当前用户不存在或不可用,未能审核!";
                    return(false);
                }
                if (ibm == null)
                {
                    errorInfo = "当前订单状态不是已分配,或当前订单不存在!";
                    return(false);
                }
                if (!(ibm.OutBillDetails.All(b => b.BillQuantity == b.AllotQuantity) &&
                      ibm.OutBillDetails.Sum(b => b.BillQuantity) == ibm.OutBillAllots.Sum(a => a.AllotQuantity)))
                {
                    errorInfo = "当前订单分配未完成或分配结果不正确!";
                    return(false);
                }
                if (!string.IsNullOrEmpty(ibm.LockTag))
                {
                    errorInfo = "当前订单其他人正在操作,请稍候重试!";
                    return(false);
                }
                using (var scope = new TransactionScope())
                {
                    if (MoveBillCreater.CheckIsNeedSyncMoveBill(ibm.WarehouseCode))
                    {
                        var moveBillMaster = MoveBillCreater.CreateMoveBillMaster(ibm.WarehouseCode, "3001", employee.ID.ToString());
                        MoveBillCreater.CreateSyncMoveBillDetail(moveBillMaster);
                        moveBillMaster.Status         = "2";
                        moveBillMaster.Description    = "出库生成同步移库单!";
                        moveBillMaster.VerifyDate     = DateTime.Now;
                        moveBillMaster.VerifyPersonID = employee.ID;
                        if (MoveBillCreater.CheckIsNeedSyncMoveBill(ibm.WarehouseCode))
                        {
                            errorInfo = "生成同步移库单不完整,请重新确认!";
                            return(false);
                        }
                        else
                        {
                            ibm.MoveBillMasterBillNo = moveBillMaster.BillNo;
                        }
                    }

                    ibm.Status     = "4";
                    ibm.UpdateTime = DateTime.Now;
                    OutBillMasterRepository.SaveChanges();
                    scope.Complete();
                    return(true);
                }
            }
            catch (Exception e)
            {
                errorInfo = "确认分配失败,详情:" + e.Message;
                return(false);
            }
        }
Esempio n. 60
0
 public EmployeeService()
 {
     _repository = new EmployeeRepository();
 }