コード例 #1
0
        public void AddIngredientToRecipe(Recipe recipe, string ingredientName, string denomination, double amount)
        {
            var ingred = WorkingUnit.Ingredients.GetAll().SingleOrDefault(x => string.Equals(x.Name, ingredientName, StringComparison.OrdinalIgnoreCase) &&
                                                                          string.Equals(x.Denomination, denomination, StringComparison.OrdinalIgnoreCase));

            if (ingred == null)
            {
                ingred = new Ingredient {
                    Id = Guid.NewGuid().ToString(), Name = ingredientName, Denomination = denomination
                };
                WorkingUnit.Ingredients.Add(ingred);
            }
            var ingDetail = new IngredientDetail()
            {
                Ingredient = ingred, Amount = amount
            };

            var checkerDetail = recipe.Ingredients.SingleOrDefault(x => x.Ingredient == ingDetail.Ingredient);

            if (checkerDetail != null)
            {
                checkerDetail.Amount += ingDetail.Amount;
                recipe.IngIdAndAmount[checkerDetail.Ingredient.Id] += amount;
            }
            else
            {
                recipe.Ingredients.Add(ingDetail);
                recipe.IngIdAndAmount.Add(ingDetail.Ingredient.Id, ingDetail.Amount);
            }
            WorkingUnit.Save();
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            WorkingUnit workingUnit = db.WorkingUnits.Find(id);

            db.WorkingUnits.Remove(workingUnit);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public Employee(int id, string surname, string forename, DateTime hiredate, WorkingUnit workingunit)
 {
     this.ID          = id;
     this.Surname     = surname;
     this.Forename    = forename;
     this.HireDate    = hiredate;
     this.WorkingUnit = workingunit;
 }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "ID,WorkingUnitName")] WorkingUnit workingUnit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(workingUnit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(workingUnit));
 }
コード例 #5
0
        public ActionResult Create([Bind(Include = "ID,WorkingUnitName")] WorkingUnit workingUnit)
        {
            if (ModelState.IsValid)
            {
                db.WorkingUnits.Add(workingUnit);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(workingUnit));
        }
コード例 #6
0
        // GET: WorkingUnitManage/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WorkingUnit workingUnit = db.WorkingUnits.Find(id);

            if (workingUnit == null)
            {
                return(HttpNotFound());
            }
            return(View(workingUnit));
        }
コード例 #7
0
 private void AddUnitToQueue_Click(object sender, RoutedEventArgs e)
 {
     if (ModelsList.SelectedIndex >= 0 && !string.IsNullOrEmpty(UnitName.Text))
     {
         Type             item     = (Type)ModelsList.SelectedItem;
         string           name     = UnitName.Text;
         WorkingUnit      instance = (WorkingUnit)Activator.CreateInstance(item);
         MessageBoxResult result   = MessageBox.Show("vous avez choisi de construire le robot " + item.Name + " qui a pour temps de construction " + instance.BuildTime + " secondes, Etes vous sur de construire ce robot", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             _dataContext.Builder.AddWorkableUnitToQueue(item, name, new Coordinates(0, 0), new Coordinates(10, 10));
             _dataContext.ForceUpdate();
         }
     }
 }
コード例 #8
0
        public void CreateRecipe(Recipe recipe)
        {
            var checker = WorkingUnit.Recipes.GetAll().SingleOrDefault(x => string.Equals(x.Name, recipe.Name, StringComparison.OrdinalIgnoreCase));

            if (checker != null)
            {
                Console.WriteLine($"Recipe {checker.Name} : {checker.Id} already exists");
                return;
            }
            if (string.IsNullOrEmpty(recipe.Id))
            {
                recipe.Id = Guid.NewGuid().ToString();
            }
            WorkingUnit.Recipes.Add(recipe);
            WorkingUnit.Save();
        }
コード例 #9
0
        public void SetCategoryInRecipe(Category category, Recipe recipe)
        {
            var retrieved = WorkingUnit.Recipes.GetAll().SingleOrDefault(x => x.CategoryId == recipe.CategoryId);

            if (retrieved != null)
            {
                Console.WriteLine($"Recipe {recipe.Name} is already in category");
                return;
            }
            else
            {
                recipe.CategoryId = category.Id;
                recipe.Category   = category;
                WorkingUnit.Save();
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: ChristopherC17/BotFactory
        static async Task MainAsync()
        {
            int    i = 5;
            object o = i;

            i = 10;

            int j = (int)o;

            Console.WriteLine(i);
            Console.WriteLine(j);
            Console.WriteLine(o);


            Vector vecteur = new Vector();

            vecteur.X = 0;
            vecteur.Y = 0;

            double lengthVector = vecteur.Length();

            Console.Write(lengthVector);

            WorkingUnit testWorkingUnit = new WorkingUnit();

            testWorkingUnit.WorkingPos = new Coordinates(3, 4);
            var result = await testWorkingUnit.WorkBegins();



            testWorkingUnit.ParkingPos = new Coordinates(10, 14);
            result = await testWorkingUnit.WorkEnds();

            if (result)
            {
                using (System.IO.StreamWriter file =
                           new System.IO.StreamWriter(@"C:\Temp\cds\test.txt"))
                {
                    file.Write(testWorkingUnit.CurrentPos.X + " y : " + testWorkingUnit.CurrentPos.Y);
                }
            }
        }
コード例 #11
0
        public void CreateCategory(Category category)
        {
            var item = WorkingUnit.Categories.GetAll().SingleOrDefault(x => string.Equals(x.Name, category.Name, StringComparison.OrdinalIgnoreCase) && x.ParentId == category.ParentId);

            if (item != null)
            {
                Console.WriteLine($"Category {item.Name} already exists!");
                return;
            }
            if (string.IsNullOrEmpty(category.Id))
            {
                category.Id = Guid.NewGuid().ToString();
            }
            if (category.Parent == null)
            {
                category.Parent = WorkingUnit.Categories.GetAll().SingleOrDefault(x => x.Id == category.ParentId);
            }
            WorkingUnit.Categories.Add(category);
            WorkingUnit.Save();
        }
コード例 #12
0
        public WorkingUnit CreateAndStoreUnit(IFactoryQueueElement fqe)
        {
            WorkingUnit unitToBeAdded = null;

            if (fqe == null)
            {
                return(null);
            }

            unitToBeAdded = Activator.CreateInstance(fqe.Model) as WorkingUnit;

            // SIMULATION DU TEMPS DE CONSTRUCTION

            Thread.Sleep(TimeSpan.FromSeconds(unitToBeAdded.BuildTime));

            // AJOUT D'UN ROBOT DANS L'ENTREPÔT

            Storage.Add(unitToBeAdded);

            QueueTime += TimeSpan.FromSeconds(unitToBeAdded.BuildTime);

            return(unitToBeAdded);
        }
コード例 #13
0
        public async Task <bool> BuildWorkableUnit()
        {
            if (Queue.Count == 0)
            {
                FactoryProgress(this, new StatusChangedEventArgs("ERROR : Queue is empty."));
                return(false);
            }

            WorkingUnit unitToBeAdded = Activator.CreateInstance(Queue.First().Model) as WorkingUnit;

            unitToBeAdded.Name = Queue.First().Name;
            //unitToBeAdded.ParkingPos = Queue.First().ParkingPos;
            //unitToBeAdded.WorkingPos = Queue.First().WorkingPos;
            Queue.Remove(Queue.First());

            QueueTime = TimeSpan.FromSeconds(unitToBeAdded.BuildTime);
            await Task.Delay(QueueTime);

            FactoryProgress(unitToBeAdded, new StatusChangedEventArgs("New robot was created and was added to Storage. It is ready to be tested."));
            Storage.Add(unitToBeAdded);

            return(true);
        }
コード例 #14
0
 public async Task Update(int id, string surname, string forename, DateTime hiredate, WorkingUnit workingunit)
 {
     await this.EmployeeRepository.UpdateAsync(new UnitEmployee(id, surname, forename, hiredate, workingunit));
 }
コード例 #15
0
        /// <summary>
        /// 开窗表格
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static MvcHtmlString DataBrowserWindow(this HtmlHelper helper, DataBrowserType type)
        {
            // 开窗元素ID
            string dataBrowser_id = "";

            // 根据枚举确定开窗类型
            Object obj = null;

            switch (type)
            {
            case DataBrowserType.Honor:
                obj            = new Honor();
                dataBrowser_id = "DataBrowser-Honor";
                break;

            case DataBrowserType.ModelWorker:
                obj            = new ModelWorker();
                dataBrowser_id = "DataBrowser-ModelWorker";
                break;

            case DataBrowserType.Proposal:
                obj            = new Proposal();
                dataBrowser_id = "DataBrowser-Proposal";
                break;

            case DataBrowserType.WorkersCongress:
                obj            = new WorkersCongress();
                dataBrowser_id = "DataBrowser-WorkersCongress";
                break;

            case DataBrowserType.WorkingTeam:
                obj            = new WorkingTeam();
                dataBrowser_id = "DataBrowser-WorkingTeam";
                break;

            case DataBrowserType.Employee:
                obj            = new Employee();
                dataBrowser_id = "DataBrowser-Employee";
                break;

            case DataBrowserType.Position:
                obj            = new Position();
                dataBrowser_id = "DataBrowser-Position";
                break;

            case DataBrowserType.WorkingUnit:
                obj            = new WorkingUnit();
                dataBrowser_id = "DataBrowser-WorkingUnit";
                break;

            case DataBrowserType.WorkingGroup:
                obj            = new WorkingGroup();
                dataBrowser_id = "DataBrowser-WorkingGroup";
                break;
            }

            // 生成表头信息
            var thead = new StringBuilder();

            thead.Append("<th></th>");

            Type t = obj.GetType();

            foreach (PropertyInfo pInfo in t.GetProperties())
            {
                thead.AppendFormat("<th>{0}</th>", pInfo.Name);
            }

            // 生成表中行信息
            var tbody = DataBrowserManager.GetTBodyString(type);

            // 生成开窗整体结构
            var result = new StringBuilder();

            result.AppendFormat(
                @"<div class='modal fade' id='{0}' tabindex='-1' role='dialog' aria-labelledby='myModalLabel-{0}' aria-hidden='true'>" +
                "<div class='modal-dialog databrowser-dialog'>" +
                "<div class='modal-content'>" +
                "<div class='modal-header'>" +
                "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>" +
                "<h4 class='modal-title' id='myModalLabel-{0}'>开窗测试</h4>" +
                "</div>" +
                "<div class='modal-body'>" +
                "<table class='table table-striped'>" +
                "<thead>" +
                "<tr>" +
                "{1}" +
                "</tr>" +
                "</thead>" +
                "<tbody>" +
                "{2}" +
                "</tbody>" +
                "</table>" +
                "</div>" +
                "<div class='modal-footer'>" +
                "<button type='button' class='btn btn-primary databrowser-ok'>选择</button>" +
                "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>" +
                "</div>" +
                "</div>" +
                "</div>" +
                "</div>", dataBrowser_id, thead, tbody
                );

            return(MvcHtmlString.Create(result.ToString()));
        }
コード例 #16
0
 public UnitEmployee(int id, string surname, string forename, DateTime hiredate, WorkingUnit workingunit) : base(id, surname, forename, hiredate, workingunit)
 {
 }