Exemple #1
0
 public NewAsutpTask(ProductionTask prodTask)
 {
     Task = new Task()
     {
         TaskNumber         = prodTask.TaskNumber,
         TaskPosition       = prodTask.TaskPosition,
         Product            = prodTask.Product,
         ProductBatchNumber = prodTask.ProductBatchNumber,
         StartSerialNumber  = prodTask.StartSerialNumber,
         ProductsAmount     = prodTask.ProductsAmount,
         PipeBatchNumber    = prodTask.PipeBatchNumber,
         PipeNumber         = prodTask.PipeNumber,
         Heat            = prodTask.Heat,
         SteelType       = prodTask.SteelType,
         Diameter        = prodTask.Diameter,
         Thickness       = prodTask.Thickness,
         PieceLength     = prodTask.PieceLength,
         PieceQuantity   = prodTask.PieceQuantity,
         CreationDate    = prodTask.CreationDate,
         StartDate       = prodTask.StartDate,
         FinishDate      = prodTask.FinishDate,
         Source          = prodTask.Source,
         PiceAmount      = prodTask.PiceAmount,
         Operator        = prodTask.Operator,
         Status          = prodTask.Status,
         PieceLength1    = prodTask.PieceLength1,
         PieceQuantity1  = prodTask.PieceQuantity1,
         Labeling1Piece1 = prodTask.Labeling1Piece1,
         Labeling2Piece1 = prodTask.Labeling2Piece1
     };
 }
Exemple #2
0
 public ProductionTaskExtended(Task task)
 {
     Task = new ProductionTask()
     {
         ID                 = task.ID,
         TaskNumber         = task.TaskNumber,
         TaskPosition       = task.TaskPosition,
         Product            = task.Product,
         ProductBatchNumber = task.ProductBatchNumber,
         StartSerialNumber  = task.StartSerialNumber,
         ProductsAmount     = task.ProductsAmount,
         PipeBatchNumber    = task.PipeBatchNumber,
         PipeNumber         = task.PipeNumber,
         Heat               = task.Heat,
         SteelType          = task.SteelType,
         Diameter           = task.Diameter,
         Thickness          = task.Thickness,
         PieceLength        = task.PieceLength,
         PieceQuantity      = task.PieceQuantity,
         CreationDate       = task.CreationDate,
         StartDate          = task.StartDate,
         FinishDate         = task.FinishDate,
         Source             = task.Source,
         PiceAmount         = task.PiceAmount,
         Operator           = task.Operator,
         Status             = task.Status,
         PieceLength1       = task.PieceLength1,
         PieceQuantity1     = task.PieceQuantity1,
         Labeling1Piece1    = task.Labeling1Piece1,
         Labeling2Piece1    = task.Labeling2Piece1
     };
     serialLabel = new ParsedSerialLabel(Task.StartSerialNumber);
 }
        public void Train(int id, int max_count = 10000, int max_pending = 10000, int priority = 10, bool blocking = false)
        {
            var units = Unary.UnitsModule;

            units.AddUnitType(id);

            var type = units.UnitTypes[id];

            if (type.Updated == false || type.IsAvailable == false)
            {
                return;
            }

            var prod = new ProductionTask()
            {
                Priority   = priority,
                Blocking   = blocking,
                WoodCost   = type.WoodCost,
                FoodCost   = type.FoodCost,
                GoldCost   = type.GoldCost,
                StoneCost  = type.StoneCost,
                Id         = id,
                MaxCount   = max_count,
                MaxPending = max_pending,
                IsTech     = false,
                IsBuilding = false
            };

            ProductionTasks.Add(prod);
        }
Exemple #4
0
        public ProductionTask GetCurrentTaskResult()
        {
            bool   success;
            string message;

            ProductionTask taskResult = new ProductionTask();

            using (OpcClient client = new OpcClient(endpoint))
            {
                client.Connect();
                object[] result = client.CallMethod(
                    "ns=3;s=\"OpcUaMethodGetTaskResult\"",
                    "ns=3;s=\"OpcUaMethodGetTaskResult\".Method"
                    );
                success = Convert.ToBoolean(result[0]);
                message = Convert.ToString(result[1]);
                if (success)
                {
                    taskResult.ID         = Convert.ToInt32(result[2]);
                    taskResult.PiceAmount = Convert.ToInt16(result[3]);
                    taskResult.Operator   = Convert.ToString(result[4]);

                    taskResult.FinishDate = DateTime.Now;
                }
                else
                {
                    throw new Exception(message);
                }
            }

            return(taskResult);
        }
Exemple #5
0
        //[ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "Order,SKU,Id,OrderKey,SKUId,DesignName,ComponentSKU,ALTSku,GraphSKU,ProductionQty,ProcessName,ProcessOrder,ProcessSetp,AltElapsedTime,ProductionLine,Equipment,OrderPlanDate,Owner,PlanStartDateTime,PlanCompletedDateTime,ActualStartDateTime,ActualCompletedDateTime,ActualElapsedTime,Status,Issue,Remark,OrderId,BomComponentId,ParentBomComponentId,CreatedUserId,CreatedDateTime,LastEditUserId,LastEditDateTime")] ProductionTask productionTask)
        {
            if (ModelState.IsValid)
            {
                productionTask.ObjectState = ObjectState.Modified;
                _productionTaskService.Update(productionTask);

                _unitOfWork.SaveChanges();
                if (Request.IsAjaxRequest())
                {
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                DisplaySuccessMessage("Has update a ProductionTask record");
                return(RedirectToAction("Index"));
            }
            var orderRepository = _unitOfWork.Repository <Order>();

            ViewBag.OrderId = new SelectList(orderRepository.Queryable(), "Id", "OrderKey", productionTask.OrderId);
            var skuRepository = _unitOfWork.Repository <SKU>();

            ViewBag.SKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", productionTask.SKUId);
            if (Request.IsAjaxRequest())
            {
                var modelStateErrors = String.Join("", this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors.Select(n => n.ErrorMessage)));
                return(Json(new { success = false, err = modelStateErrors }, JsonRequestBehavior.AllowGet));
            }
            DisplayErrorMessage();
            return(View(productionTask));
        }
        public void Research(int id, int priority = 10, bool blocking = false)
        {
            var research = Unary.ResearchModule;

            research.Add(id);

            var tech = research.Researches[id];

            if (tech.Updated == false || tech.State != ResearchState.AVAILABLE)
            {
                return;
            }

            var prod = new ProductionTask()
            {
                Priority   = priority,
                Blocking   = blocking,
                WoodCost   = tech.WoodCost,
                FoodCost   = tech.FoodCost,
                GoldCost   = tech.GoldCost,
                StoneCost  = tech.StoneCost,
                Id         = id,
                IsTech     = true,
                IsBuilding = false
            };

            ProductionTasks.Add(prod);
        }
Exemple #7
0
 public virtual void InitializeTasks()
 {
     IdleTask.Enable();
     ProductionTask.Enable();
     WorkerTask.Enable();
     ConstructionTask.Enable();
     MorphingTask.Enable();
     WorkerDefenseTask.Enable();
 }
Exemple #8
0
 public NewTask(CurrentTasks currentTasks)
 {
     task   = new ProductionTask();
     Create = new DelegateCommand(() =>
     {
         task.CreationDate = DateTime.Now;
         task.Status       = "1";
         currentTasks.InsertNewTask(task);
         TaskCreated?.Invoke();
     });
 }
Exemple #9
0
        public string getptask()
        {
            DataSet        ds = new DataSet();
            ProductionTask pt = new ProductionTask();

            ds = pt.GetPTask(20);
            ds.Tables[0].TableName = "rows";
            string str = JsonConvert.SerializeObject(ds);

            return(str);
        }
Exemple #10
0
 public NewTask(CurrentTasks currentTasks, ProductionTask task)
 {
     this.task = task;
     Create    = new DelegateCommand(() =>
     {
         this.task.Status       = "f";
         this.task.CreationDate = DateTime.Now;
         this.task.FinishDate   = DateTime.Now;
         currentTasks.InsertNewTask(this.task);
         TaskCreated?.Invoke();
     });
 }
Exemple #11
0
        // GET: ProductionTasks/Create
        public ActionResult Create()
        {
            ProductionTask productionTask = new ProductionTask();
            //set default value
            var orderRepository = _unitOfWork.Repository <Order>();

            ViewBag.OrderId = new SelectList(orderRepository.Queryable(), "Id", "OrderKey");
            var skuRepository = _unitOfWork.Repository <SKU>();

            ViewBag.SKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku");
            return(View(productionTask));
        }
Exemple #12
0
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            ProductionTask productionTask = _productionTaskService.Find(id);

            _productionTaskService.Delete(productionTask);
            _unitOfWork.SaveChanges();
            if (Request.IsAjaxRequest())
            {
                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            DisplaySuccessMessage("Has delete a ProductionTask record");
            return(RedirectToAction("Index"));
        }
Exemple #13
0
        // GET: ProductionTasks/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductionTask productionTask = _productionTaskService.Find(id);

            if (productionTask == null)
            {
                return(HttpNotFound());
            }
            return(View(productionTask));
        }
Exemple #14
0
 public virtual void InitializeTasks()
 {
     IdleTask.Enable();
     ProductionTask.Enable();
     WorkerTask.Enable();
     ConstructionTask.Enable();
     MorphingTask.Enable();
     WorkerDefenseTask.Enable();
     if (Tyr.Bot.MyRace == Race.Terran)
     {
         ConstructingSCVsTask.Enable();
     }
     GasWorkerTask.Enable();
 }
Exemple #15
0
        public IEnumerable <ProductionTask> GenerateProductionTask(int[] plansid)
        {
            var planlist = this.Queryable().Include(x => x.ProductionProcess).Where(x => plansid.Contains(x.Id)).ToList();
            var newitems = new List <ProductionTask>();

            foreach (var planitem in planlist)
            {
                var setps = _stepservice.Queryable().Include(x => x.ProductionProcess).Where(x => x.ProductionProcessId == planitem.ProductionProcessId && planitem.ProductionProcessId > 0).ToList();

                foreach (var setp in setps)
                {
                    var isexist = _taskservice.Queryable().Where(x => x.OrderId == planitem.OrderId && x.ProcessName == setp.ProductionProcess.Name && x.ProcessOrder == setp.Order).Any();
                    if (!isexist)
                    {
                        ProductionTask item = new ProductionTask();
                        item.OrderId              = planitem.OrderId;
                        item.OrderKey             = planitem.OrderKey;
                        item.OrderPlanDate        = planitem.OrderPlanDate;
                        item.ParentBomComponentId = planitem.ParentBomComponentId;
                        item.BomComponentId       = planitem.BomComponentId;
                        item.ComponentSKU         = planitem.ComponentSKU;
                        item.ProcessSetp          = setp.StepName;
                        item.ProductionLine       = setp.ProductionProcess.ProductionLine;
                        item.ProcessOrder         = setp.Order;
                        item.ProductionQty        = planitem.RequirementQty;
                        item.SKUId                 = planitem.SKUId;
                        item.GraphSKU              = planitem.GraphSKU;
                        item.ALTSku                = planitem.ALTSku;
                        item.AltElapsedTime        = planitem.RequirementQty * setp.ElapsedTime;
                        item.Equipment             = setp.Equipment;
                        item.DesignName            = planitem.DesignName;
                        item.OrderPlanDate         = planitem.OrderPlanDate;
                        item.PlanStartDateTime     = planitem.PlanedStartDate;
                        item.PlanCompletedDateTime = planitem.PlanedStartDate.Value.AddHours((double)item.AltElapsedTime);
                        item.ProcessName           = setp.ProductionProcess.Name;
                        item.Owner                 = "";
                        newitems.Add(item);
                    }
                }
            }
            _taskservice.InsertRange(newitems);
            return(newitems);
        }
Exemple #16
0
        // GET: ProductionTasks/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductionTask productionTask = _productionTaskService.Find(id);

            if (productionTask == null)
            {
                return(HttpNotFound());
            }
            var orderRepository = _unitOfWork.Repository <Order>();

            ViewBag.OrderId = new SelectList(orderRepository.Queryable(), "Id", "OrderKey", productionTask.OrderId);
            var skuRepository = _unitOfWork.Repository <SKU>();

            ViewBag.SKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", productionTask.SKUId);
            return(View(productionTask));
        }
Exemple #17
0
        protected override async Task <JToken> ExecuteController(JToken data)
        {
            var player = await new Player(PlayerId).LoadAsync();

            if (player == null)
            {
                return(JStatus.PlayerNotFound);
            }
            var building = player.GetBuildingById(BuildingId);

            if (building == null)
            {
                return(JStatus.BuildingNotFound);
            }

            if (building.ProductionTask == null)
            {
                return(JStatus.Fail);
            }

            if (string.IsNullOrEmpty(building.ProductionTask.ProducedContractMetaId))
            {
                return(JStatus.ContractNotFound);
            }

            var contractMeta = await new ContractMeta(building.ProductionTask.ProducedContractMetaId).LoadAsync();

            if (contractMeta == null)
            {
                return(JStatus.ContractNotFound);
            }

            var buildingMeta = await building.GetMetaAsync();

            if (buildingMeta == null)
            {
                return(JStatus.MetaNotFound);
            }

            foreach (var assignedCitizen in building.GetAssignedCitizens(player))
            {
                foreach (var citizenAbility in assignedCitizen.Abilities)
                {
                    await citizenAbility.ModifyProductionTaskAsync(building.ProductionTask);
                }
            }
            var prodCyclesSinceLastCheck = building.ProductionTask.Check();

            if (prodCyclesSinceLastCheck == 0)
            {
                UpdatedProductionTask = building.ProductionTask;
                return(JStatus.NotReady);
            }

            ProducedRewards = new List <Reward>();
            for (int i = 0; i < prodCyclesSinceLastCheck; i++)
            {
                var rewardList = contractMeta.Rewards.Select(r => r.Clone()).ToList();
                foreach (var reward in rewardList)
                {
                    foreach (var assignedCitizen in building.GetAssignedCitizens(player))
                    {
                        foreach (var citizenAbility in assignedCitizen.Abilities)
                        {
                            await citizenAbility.ModifyRewardAsync(reward);
                        }
                    }
                    if (reward.RollTheDice())
                    {
                        if (building.CalculateAvailableStorage(buildingMeta.StorageLimit) < reward.CalculateVolume())
                        {
                            continue;
                        }
                        else
                        {
                            building.StoredRewards.Add(reward);
                            ProducedRewards.Add(reward);
                        }
                    }
                }
            }

            if (!contractMeta.IsLoopable)
            {
                building.ProductionTask = null;
            }
            UpdatedBuildingStorage = building.StoredRewards;
            UpdatedProductionTask  = building.ProductionTask;

            if (!await player.ReplaceAsync())
            {
                OccFailFlag = true; return(JStatus.OccFail);
            }

            return(JStatus.Ok);
        }
        protected override async Task <JToken> ExecuteController(JToken data)
        {
            var player = await new Player(PlayerId).LoadAsync();

            if (player == null)
            {
                return(JStatus.PlayerNotFound);
            }
            var building = player.GetBuildingById(BuildingId);

            if (building == null)
            {
                return(JStatus.BuildingNotFound);
            }

            var buildingMeta = await building.GetMetaAsync();

            if (buildingMeta == null)
            {
                return(JStatus.BuildingNotFound);
            }
            var contractMeta = await new ContractMeta(ContractMetaId).LoadAsync();

            if (contractMeta == null)
            {
                return(JStatus.ContractNotFound);
            }

            if (!building.IsConstructed)
            {
                return(JStatus.NotReady);
            }
            if (!buildingMeta.AvailableContractMetaIds.Contains(ContractMetaId))
            {
                return(JStatus.ContractNotFound);
            }
            if (!contractMeta.Requirement.IsFulfilledByPlayer(player))
            {
                return(JStatus.RequirementNotFulfilled);
            }

            // Shouldn't produce items player already have.
            if (contractMeta.Rewards?.Count > 0 && contractMeta.Rewards.Exists(reward => reward.ItemMetaIds?.Count > 0))
            {
                var currentlyProducedItemMetaIds = new List <string>();
                foreach (var producedContractMetaId in player.GetCurrentlyProducedContractMetaIds())
                {
                    var producedContractMeta = await new ContractMeta(producedContractMetaId).LoadAsync();
                    foreach (var reward in producedContractMeta.Rewards)
                    {
                        currentlyProducedItemMetaIds.AddRange(reward.ItemMetaIds);
                    }
                }

                foreach (var reward in contractMeta.Rewards)
                {
                    if (reward?.ItemMetaIds != null)
                    {
                        foreach (var itemMetaId in reward.ItemMetaIds)
                        {
                            if (player.HasItemOfMeta(itemMetaId) || currentlyProducedItemMetaIds.Contains(itemMetaId))
                            {
                                return(JStatus.ItemDuplication);
                            }
                        }
                    }
                }
            }

            building.ProductionTask = new ProductionTask(contractMeta);

            if (!await player.ReplaceAsync())
            {
                OccFailFlag = true; return(JStatus.OccFail);
            }

            StartedProductionTask = building.ProductionTask;

            return(JStatus.Ok);
        }
        /// <summary>
        /// JUST FOR TESTING
        /// fill up all the lists and create objects
        /// </summary>
        public void fillLists()
        {
            Product product = new Product();
            product.Size = 10;

            allWPLs.Add(new WeeklyProduct(product, 20));
            allWPLs.Add(new WeeklyProduct(product, 40));
            allWPLs.Add(new WeeklyProduct(product, 60));
            allWPLs.Add(new WeeklyProduct(product, 10));

            ProductionCycle x = new ProductionCycle();
            x.AmountOfProducts = 100;
            x.ProductProduced = product;

            pc = x;

            ProductionCycleLine pc1 = new ProductionCycleLine(2, MachineType.Tank);
            ProductionCycleLine pc2 = new ProductionCycleLine(1, MachineType.Filling);

            x.PCLsRequired.Add(pc1);
            x.PCLsRequired.Add(pc2);

            List<ProductionTask> productionTasksRequired1 = pc1.ProductionTasksRequired;
            List<ProductionTask> productionTasksRequired2 = pc2.ProductionTasksRequired;

            /// remove machineType from tasks one DAY!!!!
            ProductionTask task1 = new ProductionTask(new TimeSpan(1, 1, 1), MachineType.Tank);
            ProductionTask task2 = new ProductionTask(new TimeSpan(2, 1, 1), MachineType.Tank);
            ProductionTask task3 = new ProductionTask(new TimeSpan(0, 1, 1), MachineType.Tank);
            ProductionTask task4 = new ProductionTask(new TimeSpan(5, 1, 1), MachineType.Tank);
            ProductionTask task5 = new ProductionTask(new TimeSpan(6, 1, 1), MachineType.Tank);

            ProductionTask task01 = new ProductionTask(new TimeSpan(1, 1, 1), MachineType.Filling);
            ProductionTask task02 = new ProductionTask(new TimeSpan(1, 1, 1), MachineType.Filling);
            ProductionTask task03 = new ProductionTask(new TimeSpan(1, 1, 1), MachineType.Filling);
            ProductionTask task04 = new ProductionTask(new TimeSpan(1, 1, 1), MachineType.Filling);
            ProductionTask task05 = new ProductionTask(new TimeSpan(1, 1, 1), MachineType.Filling);


            productionTasksRequired1.Add(task1);
            productionTasksRequired1.Add(task2);
            productionTasksRequired1.Add(task3);
            productionTasksRequired1.Add(task4);
            productionTasksRequired1.Add(task5);
            productionTasksRequired2.Add(task01);
            productionTasksRequired2.Add(task02);
            productionTasksRequired2.Add(task03);
            productionTasksRequired2.Add(task04);
            productionTasksRequired2.Add(task05);

            MachineEntry tank1 = new MachineEntry(MachineType.Tank);
            MachineEntry tank2 = new MachineEntry(MachineType.Tank);
            MachineEntry tank3 = new MachineEntry(MachineType.Tank);
            MachineEntry tank4 = new MachineEntry(MachineType.Tank);
            MachineEntry tank5 = new MachineEntry(MachineType.Tank);
            MachineEntry tank6 = new MachineEntry(MachineType.Tank);

            MachineSchedule msc1 = new MachineSchedule(tank1, 1);
            MachineSchedule msc2 = new MachineSchedule(tank2, 1);
            MachineSchedule msc3 = new MachineSchedule(tank3, 1);
            MachineSchedule msc4 = new MachineSchedule(tank4, 1);
            MachineSchedule msc5 = new MachineSchedule(tank5, 1);
            MachineSchedule msc6 = new MachineSchedule(tank6, 1);

            MachineEntry filling1 = new MachineEntry(MachineType.Filling);
            MachineEntry filling2 = new MachineEntry(MachineType.Filling);
            MachineEntry filling3 = new MachineEntry(MachineType.Filling);
            MachineEntry filling4 = new MachineEntry(MachineType.Filling);

            MachineSchedule msc01 = new MachineSchedule(filling1, 1);
            MachineSchedule msc02 = new MachineSchedule(filling2, 1);
            MachineSchedule msc03 = new MachineSchedule(filling3, 1);
            MachineSchedule msc04 = new MachineSchedule(filling4, 1);

            msc01.AssignedTasks.Add(task01);
            msc01.AssignedTasks.Add(task02);

            msc1.AssignedTasks.Add(task1);
            msc1.AssignedTasks.Add(task3);

            allMachines.Add(tank1);
            allMachines.Add(tank2);
            allMachines.Add(tank3);
            allMachines.Add(tank4);
            allMachines.Add(tank5);
            allMachines.Add(tank6);
            allMachines.Add(filling1);
            allMachines.Add(filling2);
            allMachines.Add(filling3);
            allMachines.Add(filling4);



        }
Exemple #20
0
 public ProductionTaskExtended(ProductionTask task)
 {
     Task        = task;
     serialLabel = new ParsedSerialLabel(Task.StartSerialNumber);
 }
Exemple #21
0
        public Main()
        {
            errorScroller = new ErrorScroller();
            errorScroller.RaiseErrorChanged += () => RaisePropertyChanged(nameof(CurrentError));
            // Работа с SQL
            currentTasks     = new CurrentTasks(errorScroller);
            checkForNewTasks = new AsutpServer(errorScroller);

            TaskList = new ObservableCollection <ProductionTask>(currentTasks.TaskList);
            ((INotifyCollectionChanged)currentTasks.TaskList).CollectionChanged += (s, a) =>
            {
                if (a.NewItems?.Count >= 1)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        foreach (ProductionTask task in a.NewItems)
                        {
                            TaskList.Add(task);
                        }
                    }));
                }
                if (a.OldItems?.Count >= 1)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        foreach (ProductionTask task in a.OldItems)
                        {
                            TaskList.Remove(task);
                        }
                    }));
                }
            };

            FinishedTaskList = new ObservableCollection <ProductionTask>(currentTasks.FinishedTaskList);
            ((INotifyCollectionChanged)currentTasks.FinishedTaskList).CollectionChanged += (s, a) =>
            {
                if (a.NewItems?.Count >= 1)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        foreach (ProductionTask task in a.NewItems)
                        {
                            FinishedTaskList.Add(task);
                        }
                    }));
                }
                if (a.OldItems?.Count >= 1)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        foreach (ProductionTask task in a.OldItems)
                        {
                            FinishedTaskList.Remove(task);
                        }
                    }));
                }
            };


            //Работа с ПЛК
            plc = new Plc();
            OpenNewTaskWindow = new DelegateCommand(() =>
            {
                NewTaskWindow newTaskWindow = new NewTaskWindow(new NewTask(currentTasks));
                newTaskWindow.ShowDialog();
            });

            StartTask = new DelegateCommand(() =>
            {
                try
                {
                    plc.SendTask(new ProductionTaskExtended(SelectedTask));
                    currentTasks.UpdateStartDate(SelectedTask.ID);
                }
                catch (Exception e)
                {
                    Log.logThis(e.Message);
                    MessageBox.Show("Нет подключения к ПЛК");
                }
                //RaisePropertyChanged(nameof(SelectedTask));
            });
            FinishTask = new DelegateCommand(() =>
            {
                try
                {
                    ProductionTask taskResult = plc.GetCurrentTaskResult();
                    taskResult.FinishDate     = DateTime.Now;
                    try
                    {
                        currentTasks.LoadTaskResult(taskResult);
                    }
                    catch (TaskNotCreatedException)
                    {
                        MessageBox.Show("Задание не найдено. Введите параметры");
                        NewTaskWindow newTaskWindow = new NewTaskWindow(new NewTask(currentTasks, taskResult));
                        newTaskWindow.ShowDialog();
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            });
            ShowCurrentTask  = new DelegateCommand(() => { VisibleCurrentTask = true; VisibleFinishedTask = false; });
            ShowFinishedTask = new DelegateCommand(() => { VisibleCurrentTask = false; VisibleFinishedTask = true; });
        }
Exemple #22
0
        static void Main(string[] args)
        {
            EmployeeWorkingSchedule ews = new EmployeeWorkingSchedule()
            {
                WorkingSchedule = new List <DailyWorkingSchedule>()
            };

            Employee assigner = new Employee()
            {
                FirstName     = "Jor",
                LastName      = "Berth",
                MiddleName    = "Mauri",
                SalaryPerHour = 2.5m
            };

            DailyWorkingSchedule dws = new DailyWorkingSchedule()
            {
                EmployeeWorkingSchedule = ews,
                WorkingDate             = DateTime.Now,
                WorkingHours            = 8
            };

            DailyWorkingSchedule dws2 = new DailyWorkingSchedule()
            {
                EmployeeWorkingSchedule = ews,
                WorkingDate             = DateTime.Now.AddDays(1),
                WorkingHours            = 8
            };

            DailyWorkingSchedule dws3 = new DailyWorkingSchedule()
            {
                EmployeeWorkingSchedule = ews,
                WorkingDate             = DateTime.Now.AddDays(2),
                WorkingHours            = 8
            };

            ews.Employee = assigner;
            ews.Position = "Proprietor";
            ews.WorkingSchedule.Add(dws);
            ews.WorkingSchedule.Add(dws2);
            ews.WorkingSchedule.Add(dws3);

            /*    using (SoenenHendrikErpContextDb context = new SoenenHendrikErpContextDb())
             *  {
             *      context.Employees.Add(assigner);
             *      context.EmployeeWorkingSchedules.Add(ews);
             *      context.SaveChanges();
             *  }*/

            Employee emp;

            using (SoenenHendrikErpContextDb context = new SoenenHendrikErpContextDb())
            {
                emp = context.Employees.Include("WorkingSchedule")
                      .Include("WorkingSchedule.WorkingSchedule").
                      FirstOrDefault(e => e.FirstName == "Jor");
            }

            Employee responsible1 = new Employee()
            {
                FirstName     = "Resnonsible",
                LastName      = "ForThe",
                MiddleName    = "Task",
                SalaryPerHour = 8.5m
            };

            List <Employee> responsible = new List <Employee>();

            responsible.Add(responsible1);

            List <Employee> responsibleForSubtask = new List <Employee>
            {
                new Employee()
                {
                    FirstName     = "Resnonsible",
                    LastName      = "ForThe",
                    MiddleName    = "SubTask",
                    SalaryPerHour = 8.5m
                }
            };

            Product productToAssemble = new Product()
            {
                Name     = "Machine",
                Price    = 300,
                Quantity = 3
            };

            List <SubTask> subtasks = new List <SubTask> {
                new ProductionSubTask()
                {
                    Assigned               = DateTime.Now,
                    Startetd               = DateTime.Now,
                    Assigner               = assigner,
                    Budget                 = 1000m,
                    Deadline               = DateTime.Now.AddDays(3),
                    IsCompleted            = false,
                    ReportProgressInterval = 60,
                    Title              = "Some tasks to do subtask",
                    Status             = Status.InProgress,
                    Hello              = "Heloo from sub task",
                    ResponsiblePersons = responsibleForSubtask
                }
            };

            ProductionTask t = new ProductionTask()
            {
                Assigned               = DateTime.Now,
                Startetd               = DateTime.Now,
                Assigner               = assigner,
                Budget                 = 1000m,
                Deadline               = DateTime.Now.AddDays(3),
                IsCompleted            = false,
                ReportProgressInterval = 60,
                Title              = "Some tasks to do",
                Status             = Status.InProgress,
                Product            = productToAssemble,
                SubTasks           = subtasks,
                ResponsiblePersons = responsible
            };


            using (var context = new SoenenHendrikErpContextDb())
            {
                context.Tasks.Add(t);
                context.SaveChanges();
            }

            List <ProductionTask> tasks = new List <ProductionTask>();

            using (var context = new SoenenHendrikErpContextDb())
            {
                tasks = context.Tasks.Include("Product").Include("Assigner")
                        .Include("ResponsiblePersons")
                        .Include("SubTasks").OfType <ProductionTask>().ToList();
            }


            Console.WriteLine("ss");
        }