public SalonUnitWorker(SalonContext context)
 {
     _context         = context;
     Clients          = new ClientRepository(_context);
     Workers          = new WorkerRepository(_context);
     ChargeOfAccounts = new ChargeOfAccountRepository(_context);
 }
Beispiel #2
0
        public void TestBookingRequest()
        {
            var request = new BookingRequest
            {
                BookingId = "",
                Guest     = new Customer {
                    EMailAddress = "*****@*****.**", FirstName = "Mudlappa", LastName = "Narayanappa"
                },
                RequestedRooms = new List <RoomRequest>
                {
                    new RoomRequest
                    {
                        RequestedRoom = new Room {
                            Id = "1", Description = "", Title = "Delux Room"
                        },
                        RoomCount = 2
                    }
                },
                TravelDetails = new Itinerary {
                    FromDate = DateTime.Now.Date.AddDays(1), ToDate = DateTime.Now.Date.AddDays(2), HotelID = ""
                }
            };

            var response = new WorkerRepository().AddBooking(request);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.ConfirmationNumber);
        }
Beispiel #3
0
 private Logic()
 {
     log        = new DAL.Logger.Logger();
     storeItems = new StoreItemRepository();
     workers    = new WorkerRepository();
     LoggedIn  += User_LoggedIn;
 }
        public async Task CancelTask(int taskId)
        {
            var server = await WorkerRepository.GetServerByAssignedTaskId(taskId);

            _connectionService.SendBytes(Bytes.type["cancel_task"], server.IpAddress, server.Port);
            await TaskRepository.UpdateTaskStatus(taskId, "Disposed");
        }
        public WorkerController()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["WorkerManager"].ConnectionString;

            repo        = new WorkerRepository(connectionString);
            companyRepo = new CompanyRepository(connectionString);
        }
Beispiel #6
0
        public OctopusAsyncRepository(IOctopusAsyncClient client, RepositoryScope repositoryScope = null)
        {
            Client                    = client;
            Scope                     = repositoryScope ?? RepositoryScope.Unspecified();
            Accounts                  = new AccountRepository(this);
            ActionTemplates           = new ActionTemplateRepository(this);
            Artifacts                 = new ArtifactRepository(this);
            Backups                   = new BackupRepository(this);
            BuiltInPackageRepository  = new BuiltInPackageRepositoryRepository(this);
            CertificateConfiguration  = new CertificateConfigurationRepository(this);
            Certificates              = new CertificateRepository(this);
            Channels                  = new ChannelRepository(this);
            CommunityActionTemplates  = new CommunityActionTemplateRepository(this);
            Configuration             = new ConfigurationRepository(this);
            DashboardConfigurations   = new DashboardConfigurationRepository(this);
            Dashboards                = new DashboardRepository(this);
            Defects                   = new DefectsRepository(this);
            DeploymentProcesses       = new DeploymentProcessRepository(this);
            Deployments               = new DeploymentRepository(this);
            Environments              = new EnvironmentRepository(this);
            Events                    = new EventRepository(this);
            FeaturesConfiguration     = new FeaturesConfigurationRepository(this);
            Feeds                     = new FeedRepository(this);
            Interruptions             = new InterruptionRepository(this);
            LibraryVariableSets       = new LibraryVariableSetRepository(this);
            Lifecycles                = new LifecyclesRepository(this);
            MachinePolicies           = new MachinePolicyRepository(this);
            MachineRoles              = new MachineRoleRepository(this);
            Machines                  = new MachineRepository(this);
            Migrations                = new MigrationRepository(this);
            OctopusServerNodes        = new OctopusServerNodeRepository(this);
            PerformanceConfiguration  = new PerformanceConfigurationRepository(this);
            PackageMetadataRepository = new PackageMetadataRepository(this);
            ProjectGroups             = new ProjectGroupRepository(this);
            Projects                  = new ProjectRepository(this);
            ProjectTriggers           = new ProjectTriggerRepository(this);
            Proxies                   = new ProxyRepository(this);
            Releases                  = new ReleaseRepository(this);
            RetentionPolicies         = new RetentionPolicyRepository(this);
            Schedulers                = new SchedulerRepository(this);
            ServerStatus              = new ServerStatusRepository(this);
            Spaces                    = new SpaceRepository(this);
            Subscriptions             = new SubscriptionRepository(this);
            TagSets                   = new TagSetRepository(this);
            Tasks                     = new TaskRepository(this);
            Teams                     = new TeamsRepository(this);
            Tenants                   = new TenantRepository(this);
            TenantVariables           = new TenantVariablesRepository(this);
            UserInvites               = new UserInvitesRepository(this);
            UserRoles                 = new UserRolesRepository(this);
            Users                     = new UserRepository(this);
            VariableSets              = new VariableSetRepository(this);
            Workers                   = new WorkerRepository(this);
            WorkerPools               = new WorkerPoolRepository(this);
            ScopedUserRoles           = new ScopedUserRoleRepository(this);
            UserPermissions           = new UserPermissionsRepository(this);

            loadRootResource      = new Lazy <Task <RootResource> >(LoadRootDocumentInner, true);
            loadSpaceRootResource = new Lazy <Task <SpaceRootResource> >(LoadSpaceRootDocumentInner, true);
        }
        public async Task SendTask(int taskId)
        {
            await _locker.WaitAsync();

            try
            {
                int[,] task = await ReadStoredTask(taskId);

                byte[] matrixSize = ByteConverter.GetByteMatrixSize(task);
                byte[] matrix     = ByteConverter.GetBytes(task);
                byte[] buffer     = new byte[268435456];

                WorkerServerDto server = await WorkerRepository.GetServerByAssignedTaskId(taskId);

                matrixSize = matrixSize.AddPrefix(Bytes.byteDef["size_prefix"]);
                matrix     = matrix.AddPrefix(Bytes.byteDef["task_prefix"]);

                _connectionService.SendBytes(matrixSize, server.IpAddress, server.Port);
                _connectionService.ReceiveBytes(ref buffer, server.IpAddress, server.Port);

                _connectionService.SendBytes(matrix, server.IpAddress, server.Port);
                _connectionService.ReceiveBytes(ref buffer, server.IpAddress, server.Port);

                await TaskRepository.UpdateTaskStatus(taskId, "Working");
            }
            finally
            {
                _locker.Release();
            }
        }
        public async Task CollectResultIfReady(int taskId)
        {
            byte[] buffer = new byte[268435456];

            var server = await WorkerRepository.GetServerByAssignedTaskId(taskId);

            var task = await TaskRepository.GetTask(taskId);

            var matrix = new int[task.Size, task.Size];

            _connectionService.SendBytes(Bytes.type["collect_data"], server.IpAddress, server.Port);
            _connectionService.ReceiveBytes(ref buffer, server.IpAddress, server.Port);

            if (buffer[0] == Bytes.byteDef["ready_prefix"])
            {
                buffer = buffer.RemovePrefix();

                ByteConverter.SetMatrixFromBytes(buffer, ref matrix);

                StoreTaskResult(matrix, taskId);

                await TaskRepository.UpdateTaskStatus(taskId, "Done");

                await TaskRepository.UnAssignTask(taskId);
            }
            else if (buffer[0] == Bytes.byteDef["notyet_prefix"])
            {
                return;
            }
        }
Beispiel #9
0
 public UnitOfWork(RestaurantContext context)
 {
     _context           = context;
     Adjustments        = new AdjustmentRepository(_context);
     AdjustmentsItems   = new AdjustmentItemRepository(_context);
     Branches           = new BranchRepository(_context);
     Categories         = new CategoryRepository(_context);
     Customers          = new CustomerRepository(_context);
     Deliveries         = new DeliveryRepository(_context);
     DeliveryItems      = new DeliveryItemRepository(_context);
     Divisions          = new DivisionRepository(_context);
     Expirations        = new ExpirationRepository(_context);
     Groups             = new GroupRepository(_context);
     Stocks             = new InventoryItemRepository(_context);
     Locations          = new LocationRepository(_context);
     Units              = new MeasurementUnitRepository(_context);
     Productions        = new ProductionRepository(_context);
     Ingredients        = new ProductionItemRepository(_context);
     Products           = new ProductRepository(_context);
     Purchases          = new PurchaseRepository(_context);
     PurchaseItems      = new PurchaseItemRepository(_context);
     PurchaseOrders     = new PurchaseOrderRepository(_context);
     PurchaseOrderItems = new PurchaseOrderItemRepository(_context);
     SalesInvoices      = new SalesInvoiceRepository(_context);
     SalesInvoiceItems  = new SalesInvoiceItemRepository(_context);
     Suppliers          = new SupplierRepository(_context);
     Transfers          = new TransferRepository(_context);
     TransferItems      = new TransferItemRepository(_context);
     Wastages           = new WastageRepository(_context);
     WastageItems       = new WastageItemRepository(_context);
     Workers            = new WorkerRepository(_context);
     ItemLocation       = new ItemLocationRepository(_context);
     StockHistory       = new StockHistoryRepository(_context);
     Currencies         = new CurrencyRepository(_context);
 }
        public ActionResult WorkerProfile()
        {
            var workerModel = new WorkerRepository(new BaseContext())
                              .getWorkerModel(User.Identity.GetUserId <int>());

            return(View(workerModel));
        }
        public List <Notification> GetNotifications()
        {
            var notifications = new List <Notification>();
            var trucksLink    = "/Truck/EditTruck?truckId={0}";
            var workersLink   = "/Worker/EditWorker?workerId={0}";
            var trucks        = new TruckRepository().GetTrucks();
            var workers       = new WorkerRepository().GetWorkers();

            foreach (var truck in trucks)
            {
                var pageLink = string.Format(trucksLink, truck.Id);
                notifications.Add(GetNotificationForDate(NotificationWarnnings.ITPWillExpire, NotificationWarnnings.ITPExpired, truck.ITPExpirationDate, truck.ITPExpirationDateString, truck.RegistrationNumber, pageLink, true));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.InsuranceWillExpire, NotificationWarnnings.InsuranceExpired, truck.InsuranceExpirationDate, truck.InsuranceExpirationDateString, truck.RegistrationNumber, pageLink, true));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.TahografWillExpire, NotificationWarnnings.TahografExpired, truck.TachographExpirationDate, truck.TachographExpirationDateString, truck.RegistrationNumber, pageLink, true));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.ConformCopyWillExpire, NotificationWarnnings.ConformCopyWillExpire, truck.ConformCopyExpirationDate, truck.ConformCopyExpirationDateString, truck.RegistrationNumber, pageLink, true));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.VignetteNLWillExpire, NotificationWarnnings.VignetteNLWillExpire, truck.VignetteExpirationDateNL, truck.VignetteExpirationDateNLString, truck.RegistrationNumber, pageLink, true));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.VignetteROWillExpire, NotificationWarnnings.VignetteROWillExpire, truck.VignetteExpirationDateRO, truck.VignetteExpirationDateROString, truck.RegistrationNumber, pageLink, true));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.VignetteUKWillExpire, NotificationWarnnings.VignetteUKExpired, truck.VignetteExpirationDateUK, truck.VignetteExpirationDateUKString, truck.RegistrationNumber, pageLink, true));
            }
            foreach (var worker in workers)
            {
                var pageLink = string.Format(workersLink, worker.Id);
                notifications.Add(GetNotificationForDate(NotificationWarnnings.PermitWillExpire, NotificationWarnnings.PermitExpired, worker.DrivingLicenseExpirationDate, worker.DrivingLicenseExpirationDateString, worker.WorkerName, pageLink, false));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.CertificateWillExpire, NotificationWarnnings.CertificateExpired, worker.CertificateExpirationDate, worker.CertificateExpirationDateString, worker.WorkerName, pageLink, false));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.TahografCardWillExpire, NotificationWarnnings.TahografCardExpired, worker.TachographCardExpirationDate, worker.TachographCardExpirationDateString, worker.WorkerName, pageLink, false));
                notifications.Add(GetNotificationForDate(NotificationWarnnings.MedicalWillExpire, NotificationWarnnings.MedicalExpired, worker.MedicalTestsExpirationDate, worker.MedicalTestsExpirationDateString, worker.WorkerName, pageLink, false));
            }
            notifications = GetNotificationThatAreNotNull(notifications);
            return(notifications.OrderByDescending(x => x.NotificationDate).ToList());
        }
 public WorkerData()
 {
     InitializeComponent();
     _worker   = new WorkerRepository();
     _position = new PositionRepository();
     _company  = new CompanyRepository();
 }
Beispiel #13
0
        public void TestCancellationRequest()
        {
            var request = new CancellationRequest {
                BookingNumber = "D35F673C-728F-447C-9872-F6F8D05CE0C7", ConfirmationNumber = "100", LastName = "Narayanappa"
            };
            var response = new WorkerRepository().CancelBooking(request);

            Assert.IsNotNull(response);
        }
Beispiel #14
0
        public UnitOfWork(DbContextOptions contextOptions)
        {
            _context = new DatabaseContext(contextOptions);

            Employers = new EmployerRepository(_context);
            Workers   = new WorkerRepository(_context);

            Migrate();
        }
Beispiel #15
0
        public UnitOfWork()
        {
            context = new Context();

            Enrollments     = new EnrollmentRepository(context);
            Positions       = new PositionRepository(context);
            Workers         = new WorkerRepository(context);
            WorkerPositions = new WorkerPositionRepository(context);
        }
 public EditWorker()
 {
     InitializeComponent();
     _worker               = new WorkerRepository();
     _company              = new CompanyRepository();
     _position             = new PositionRepository();
     birthDate.MaximumDate = DateTime.Now;
     birthDate.MinimumDate = DateTime.Now.AddYears(-100);
 }
Beispiel #17
0
        public RequestsDistributor(IHubContext <DistributeHub, ITypedHubClient> hub)
        {
            var Context = new UnitOfWork();

            workerRepository   = Context.Repository <Worker>() as WorkerRepository;
            requestRepository  = Context.Repository <Request>() as RequestRepository;
            settingsRepository = Context.Repository <Settings>() as SettingsRepository;
            hubContext         = hub;
        }
        public async Task UpdateTaskProgress(int taskId)
        {
            byte[] buffer = new byte[268435456];
            var    server = await WorkerRepository.GetServerByAssignedTaskId(taskId);

            _connectionService.SendBytes(Bytes.type["progress_request"], server.IpAddress, server.Port);
            _connectionService.ReceiveBytes(ref buffer, server.IpAddress, server.Port);
            buffer = buffer.RemovePrefix();
            await TaskRepository.UpdateTaskPercent(taskId, buffer[0]);
        }
Beispiel #19
0
        public void TestReservationStatus()
        {
            var request = new BookingStatusRequest {
                BookingNumber = "D35F673C-728F-447C-9872-F6F8D05CE0C7", LastName = "Narayanappa"
            };
            var response = new WorkerRepository().GetBookingStatus(request);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.StatusCode);
        }
Beispiel #20
0
        public FluentRecordBase AddRepoWorker()
        {
            if (_dbFactory == null)
            {
                AddDBFactory();
            }

            _repoW = new WorkerRepository(_dbFactory);
            return(this);
        }
Beispiel #21
0
        public Worker CreateWorker(WorkerRequest Worker)
        {
            var entityToInsert = new Worker()
            {
                User = this.UserRepository.GetById(Worker.UserId)
            };

            WorkerRepository.Insert(entityToInsert);
            return(entityToInsert);
        }
Beispiel #22
0
        public Worker GetById(int WorkerId)
        {
            var Worker = WorkerRepository.GetById(WorkerId);

            if (Worker == null)
            {
                throw new BadRequestException(ErrorMessages.TrabajadorNoEncontrado);
            }

            return(Worker);
        }
        /// <summary>
        /// Creates a new instance of the CmsWorker class
        /// </summary>
        /// <param name="workerRepository">A worker repository to store event data in</param>
        /// <param name="logEntryRepository">A LogEntry repository implementation to use when building the underlying logger</param>
        /// <param name="errorRepository">An Error repository implementation for handling the creation of worker errors</param>
        /// <param name="messageBus">An optional message bus to use for the worker and logger</param>
        public CmsWorker(WorkerRepository workerRepository, IRepository <LogEntry> logEntryRepository, IRepository <AuditableError> errorRepository, MessageBus messageBus = null)
        {
            this.MessageBus = messageBus;

            this.Logger = new Logger(this, messageBus, logEntryRepository, errorRepository);

            this.WorkerRepository = workerRepository;

            MessageBus.SubscribeAll(TypeFactory.GetAllImplementations(typeof(IMessageHandler)));

            this.UpdateLastRun();
        }
        public OctopusAsyncRepository(IOctopusAsyncClient client)
        {
            this.Client = client;

            Accounts                 = new AccountRepository(client);
            ActionTemplates          = new ActionTemplateRepository(client);
            Artifacts                = new ArtifactRepository(client);
            Backups                  = new BackupRepository(client);
            BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client);
            CertificateConfiguration = new CertificateConfigurationRepository(client);
            Certificates             = new CertificateRepository(client);
            Channels                 = new ChannelRepository(client);
            CommunityActionTemplates = new CommunityActionTemplateRepository(client);
            Configuration            = new ConfigurationRepository(client);
            DashboardConfigurations  = new DashboardConfigurationRepository(client);
            Dashboards               = new DashboardRepository(client);
            Defects                  = new DefectsRepository(client);
            DeploymentProcesses      = new DeploymentProcessRepository(client);
            Deployments              = new DeploymentRepository(client);
            Environments             = new EnvironmentRepository(client);
            Events = new EventRepository(client);
            FeaturesConfiguration = new FeaturesConfigurationRepository(client);
            Feeds                    = new FeedRepository(client);
            Interruptions            = new InterruptionRepository(client);
            LibraryVariableSets      = new LibraryVariableSetRepository(client);
            Lifecycles               = new LifecyclesRepository(client);
            MachinePolicies          = new MachinePolicyRepository(client);
            MachineRoles             = new MachineRoleRepository(client);
            Machines                 = new MachineRepository(client);
            Migrations               = new MigrationRepository(client);
            OctopusServerNodes       = new OctopusServerNodeRepository(client);
            PerformanceConfiguration = new PerformanceConfigurationRepository(client);
            ProjectGroups            = new ProjectGroupRepository(client);
            Projects                 = new ProjectRepository(client);
            ProjectTriggers          = new ProjectTriggerRepository(client);
            Proxies                  = new ProxyRepository(client);
            Releases                 = new ReleaseRepository(client);
            RetentionPolicies        = new RetentionPolicyRepository(client);
            Schedulers               = new SchedulerRepository(client);
            ServerStatus             = new ServerStatusRepository(client);
            Subscriptions            = new SubscriptionRepository(client);
            TagSets                  = new TagSetRepository(client);
            Tasks                    = new TaskRepository(client);
            Teams                    = new TeamsRepository(client);
            Tenants                  = new TenantRepository(client);
            TenantVariables          = new TenantVariablesRepository(client);
            UserRoles                = new UserRolesRepository(client);
            Users                    = new UserRepository(client);
            VariableSets             = new VariableSetRepository(client);
            Workers                  = new WorkerRepository(client);
            WorkerPools              = new WorkerPoolRepository(client);
        }
Beispiel #25
0
    public void RegisterAndRetrieveWorkers()
    {
        var repo = new WorkerRepository();

        repo.RegisterWorker(new WorkerA());
        var workerA = repo.RetrieveWorkerForWorkItem(new WorkItemA());

        Assert.IsTrue(workerA is WorkerA);

        repo.RegisterWorker(new WorkerB());
        var workerB = repo.RetrieveWorkerForWorkItem(new WorkItemB());

        Assert.IsTrue(workerB is WorkerB);
    }
        public override void SetWorkingHours(int hours, string date)
        {
            if (DateTime.Parse(date) > DateTime.Today)
            {
                throw new ArgumentException("Дата не может быть позже сегодняшнего дня!");
            }
            WorkerRepository.SetFileName(this);
            WorkerRepository.LoadWorkersToString();
            RefactorStringParameters.Worker = this;
            var parameters = RefactorStringParameters.FindOrCreateNewNote(date, hours);

            RefactorStringParameters.RefactorListWorkers(parameters, hours, date);
            WorkerRepository.ListWorkers.Sort();
            WorkerRepository.WriteWorkersToString();
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    _logger.LogInformation("Started jobs at: {time}", DateTimeOffset.Now);

                    var servers = await WorkerRepository.GetWorkerServer();

                    _logger.LogInformation("Loaded servers: {0}", servers.Count);

                    servers.ForEach(s => _connectionService.ConnectToExistingServer(s.IpAddress, s.Port));

                    var unassignedTasks = await _computeTaskService.GetUnassignedTasks();

                    _logger.LogInformation("Got unassigned tasks: {0}", unassignedTasks.Count);

                    await unassignedTasks.ForEachAsync(async t => await _computeTaskService.AssignTask(t.TaskID));

                    var taskToCancel = await _computeTaskService.GetCanceledTasks();

                    await taskToCancel.ForEachAsync(async t => await _computeTaskService.CancelTask(t.TaskID));

                    var assignedTasksId = await _computeTaskService.GetIdToSendList();

                    _logger.LogInformation("Got assigned tasks: {0}", assignedTasksId.Count);

                    await assignedTasksId.ForEachAsync(async t => await _computeTaskService.SendTask(t));

                    var workingTasks = await TaskRepository.GetWorkingTasks();

                    await workingTasks.ForEachAsync(async t => await _computeTaskService.UpdateTaskProgress(t.TaskID));

                    _logger.LogInformation("Updated tasks progress");

                    await workingTasks.ForEachAsync(async t => await _computeTaskService.CollectResultIfReady(t.TaskID));

                    _logger.LogInformation("Checked tasks results");
                    _locker.Release();
                }
                catch (Exception e)
                {
                    _logger.LogError(e.Message);
                }
                await Task.Delay(TimeSpan.FromSeconds(2), stoppingToken);
            }
        }
Beispiel #28
0
        public ActionResult Login(LoginModel data)
        {
            IWorkerRepository workerRepository = new WorkerRepository();
            bool workerExist = workerRepository.LogIn(data.Login, data.Password);


            if (ModelState.IsValid && workerExist != false)
            {
                string cookieValue = data.Login.ToString();
                var    cookie      = new HttpCookie("LogOn", cookieValue);
                Response.AppendCookie(cookie);
                return(RedirectToAction("OrderList", "Order"));
            }
            else
            {
                return(View());
            }
        }
Beispiel #29
0
        public List <Worker> GetAll()
        {
            var users = WorkerRepository.GetAll();

            if (users == null)
            {
                throw new BadRequestException(ErrorMessages.UserNoEncontrado);
            }

            var result     = new List <Worker>();
            var enumerator = users.GetEnumerator();

            while (enumerator.MoveNext())
            {
                result.Add(enumerator.Current);
            }
            return(result);
        }
Beispiel #30
0
        public async Task <bool> EstablishConnection(string ipAddress, int port = 9915)
        {
            try
            {
                connectionsDictionary.Add(ParseIpPort(ipAddress, port), _connectionFactory.GenerateConnection(ipAddress, port));
                await WorkerRepository.AddNewWorkerServer(new WorkerServerDto
                {
                    IpAddress   = ipAddress,
                    IsConnected = true,
                    Port        = port
                });

                return(true);
            }
            catch
            {
                return(false);
            }
        }