Example #1
0
        private void WorkDone(FinishWork finishWork)
        {
            var material = finishWork.Message as MaterialRequest;

            _SimulationContext.Tell(new MachineJobDistributor.ProductionOrderFinished(material, Context.Parent), Self);
            //Console.WriteLine("Time: " + TimePeriod + " - " + Self.Path + " Finished: " + material.Material.Name);
        }
Example #2
0
        private void StartScientistWork(int scientistId)
        {
            _semaphore.WaitOne();
            StopAllWorkingThreads += () => { _scientists[scientistId].workFinished = true; };
            int resolved = _scientists[scientistId].StartWork();

            lock (researchLocker)
            {
                if (researchAlreadyEnded)
                {
                    return;
                }

                research.PushProgress(resolved);
                if (research.IsResearchResolved())
                {
                    StopAllWorkingThreads?.Invoke();

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Researching ended!");
                    TimeSpan timeSpent = research.GetResearchResolvingTime();
                    Console.WriteLine($"Spent {timeSpent.Days} dd {timeSpent.Hours}:{timeSpent.Minutes}:{timeSpent.Seconds} {timeSpent.Milliseconds} ms");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine();
                    researchAlreadyEnded = true;
                    return;
                }
            }
            _semaphore.Release();
            Thread thread = new Thread(() => StartScientistWork(scientistId));

            thread.Start();
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, FinishWorkCreateModelView finishWork)
        {
            if (ModelState.IsValid)
            {
                var finish = new FinishWork()
                {
                    CashAdvance          = finishWork.CashAdvance,
                    CashAdvanceAmont     = finishWork.CashAdvanceAmont,
                    DateDelgation        = finishWork.DateDelgation,
                    DelegationBudy       = finishWork.DelegationBudy,
                    DelegationNumber     = finishWork.DelegationNumber,
                    FoodsBuy             = finishWork.FoodsBuy,
                    JopDegree            = finishWork.JopDegree,
                    LivingBuy            = finishWork.LivingBuy,
                    TransportBuy         = finishWork.TransportBuy,
                    TransportToToWorkBuy = finishWork.TransportToToWorkBuy,
                    TripBookingId        = finishWork.TripBookingId,
                    TripDelegateId       = finishWork.TripDelegateId,
                    Id = finishWork.Id, EndWorkDuration = finishWork.EndWorkDuration
                };
                _context.Update(finish);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(IndexByBoking), new { bokingId = finish.TripBookingId }));
            }
            return(View(finishWork));
        }
Example #4
0
        //обрабатываем данное количество заявок, после чего обработка покупок прекращается
        public void DistributeToDeps(int PurchaseAmount, object context)
        {
            var syncContext = context as SynchronizationContext;
            var rand        = new Random();

            while (Purchased < PurchaseAmount)
            {
                TrySendPurchase(syncContext);
                Thread.Sleep(rand.Next(5000, 7000));
                ++Purchased;
            }
            syncContext?.Send(obj => FinishWork?.Invoke(), null);
        }
Example #5
0
    public void Fuser(FinishWork work, SqlDataReader reader)
    {
        ((Button)work.FindControl("name")).Text   = reader.GetString(2);
        ((Label)work.FindControl("time")).Text    = reader.GetString(3);
        ((Label)work.FindControl("where")).Text   = reader.GetString(4);
        ((Label)work.FindControl("renshu")).Text  = reader.GetInt32(6).ToString();
        ((Label)work.FindControl("gongzi1")).Text = reader.GetInt32(7).ToString();

        ((Label)work.FindControl("name1")).Text        = ((Button)work.FindControl("name")).Text;
        ((Label)work.FindControl("time1")).Text        = ((Label)work.FindControl("time")).Text;
        ((Label)work.FindControl("where1")).Text       = ((Label)work.FindControl("where")).Text;
        ((Label)work.FindControl("jieshao1")).Text     = reader.GetString(3);
        ((Label)work.FindControl("renshu1")).Text      = ((Label)work.FindControl("renshu")).Text;
        ((Label)work.FindControl("gongzidaiyu1")).Text = ((Label)work.FindControl("gongzi1")).Text;
    }
        public void Split(string inputFile, string outputDir, bool inPlace, int splitNum)
        {
            BeginningWork?.Invoke(this, splitNum + 1);

            if (inPlace)
            {
                InPlaceSplit(inputFile, outputDir, splitNum);
            }
            else
            {
                CopySplit(inputFile, outputDir, splitNum);
            }

            FinishWork?.Invoke(this, EventArgs.Empty);
        }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Label6.Text = Session["PrincipalName"].ToString();
        SqlDataReader sqlData = DAL.ManagerDAL.SelectJob(Session["account"].ToString());

        while (sqlData.Read())
        {
            if (sqlData.GetString(8).Trim() == "4")
            {
                FinishWork work = (FinishWork)LoadControl("FinishWork.ascx");
                work.Fuser(work, sqlData);

                Panel3.Controls.Add(work);
            }
        }
    }
Example #8
0
        public event Action FinishWork;                                 //работа магазина окончена

        public PetShop()
        {
            PurchaseQueue    = new Queue <Purchase>();
            PurchaseCreation = new PurchaseQueueCreation(PurchaseQueue);
            DepartmentChain  = CreateDepartments();
            Cart             = new ShoppingCart(DepartmentChain, PurchaseQueue);
            //подключаем обработчики событий добавления покупки в корзину (откуда она пойдет в отделы),
            //откладывания покупки (если отдел занят) и окончания работы магазина
            Cart.PurchaseInProcess += purchase => PurchaseToDep?.Invoke(purchase);
            Cart.PostponePurchase  += purchase => PostponePurchase?.Invoke(purchase);
            Cart.FinishWork        += () => FinishWork?.Invoke();
            //подключаем обработчики событий добавления/откладывания (если доставщик занят)/изменений на складе/доставки покупки для отделов
            PurchaseCreation.AddPurchase += purchase => NewPurchase?.Invoke(purchase);
            DepartmentChain.AddStockChanges(department => StockChanges?.Invoke(department));
            DepartmentChain.AddContractionAction((purchase, contractor) => ContractionFinished?.Invoke(purchase, contractor));
            DepartmentChain.AddDeliveryAtion((purchase, deliverer) => DeliveryFinished?.Invoke(purchase, deliverer));
        }