コード例 #1
0
ファイル: Sprint.RunList.cs プロジェクト: rvanderbrugge/blu
        public Function BuildRunList()
        {
            ReturnType rt = new ReturnType();

            Logger.log("info", "Building run list...");
            RegistryHelper rh = new RegistryHelper {
                SubKey = "SOFTWARE\\Blu\\Runtime\\RunList\\"
            };

            rh.DeleteSubKeyTree();

            List <object> draftRunlist = (List <object>)ChefEndpoint.Get("nodes/" + ChefConfig.NodeName, "run_list").Object;

            // TODO: handle roles in the runlist
            // Only extract recipe[] runlist for now, role[] is not handled yet
            foreach (string item in draftRunlist)
            {
                Cookbook cookbook     = new Cookbook();
                string   recipe       = item.StringBetween("recipe[", "]");
                string[] runlistItem  = Regex.Split(recipe, @"::");
                string   cookbookName = runlistItem[0];

                // Add runlist item to sprint runlist
                string recipeName        = runlistItem.Count() < 2 ? "default" : runlistItem[1];
                string sprintRunListItem = SprintData.RunlistPath + "\\" + cookbookName + "\\recipes\\" + recipeName + ".rb";
                SprintData.SprintRunList.Add(sprintRunListItem);

                // Download cookbooks and extract resource/attribute list
                rt = cookbook.Download(cookbookName, String.Empty, String.Empty, String.Empty, true, true, true);
                SprintData.ResourceFileList.AddRange(cookbook.ResourceList);
                SprintData.AttributeFileList.AddRange(cookbook.AttributeList);
            }
            return(rt);
        }
コード例 #2
0
 public void Post([FromBody] Cookbook cookbook)
 {
     if (ModelState.IsValid)
     {
         cookbookRepository.Add(cookbook);
     }
 }
コード例 #3
0
        protected override void ProcessRecord()
        {
            AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => Assembly.Load(AssemblyResolver.ResolveAssembly(args));
            ChefConfigurator chefConfigurator = new ChefConfigurator();

            chefConfigurator.LoadConfig();
            // ChefConfig.apiLog = false;

            // Default -Version to _latest
            if (Version == null)
            {
                Version = "_latest";
            }

            Cookbook   cookbook = new Cookbook();
            ReturnType rt       = cookbook.Download(Name, Version);

            if (rt.Result == 0)
            {
                Logger.log("ok", "Added cookbook: " + Name + "[" + Version + "] to cookbook path.");
            }
            else
            {
                Logger.log("error", rt.Message);
                Logger.log("error", "There is an error adding cookbook: " + Name + "[" + Version + "].");
                Terminate(rt.Message);
            }
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("CookbookId,Name")] Cookbook cookbook)
        {
            if (id != cookbook.CookbookId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cookbook);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CookbookExists(cookbook.CookbookId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(cookbook));
        }
コード例 #5
0
        static void test(string[] lines)
        {
            Cookbook book  = new Cookbook(lines);
            Block    block = new Block
            {
                values = new bool[, ]
                {
                    { false, true, false },
                    { false, false, true },
                    { true, true, true },
                },
            };

            for (int i = 0; i < 5; i++)
            {
                block = book.cook(block);
            }
            Console.WriteLine(block.on);

            // part2: really?...
            for (int i = 5; i < 18; i++)
            {
                block = book.cook(block);
            }
            Console.WriteLine(block.on);
        }
コード例 #6
0
 public void Put(int cookbookId, [FromBody] Cookbook cookbook)
 {
     cookbook.CookbookId = cookbookId;
     if (ModelState.IsValid)
     {
         cookbookRepository.Update(cookbook);
     }
 }
コード例 #7
0
ファイル: FeedDataCall.cs プロジェクト: rywem/Eyon
        public async Task RemoveFeedCookbookAsync(Feed feed, Cookbook cookbook)
        {
            var feedCookbook = await _unitOfWork.FeedCookbook.GetFirstOrDefaultAsync(x => x.FeedId == feed.Id && x.CookbookId == cookbook.Id);

            if (feedCookbook != null)
            {
                RemoveFeedCookbook(feedCookbook);
            }
        }
コード例 #8
0
ファイル: FeedDataCall.cs プロジェクト: rywem/Eyon
        public void RemoveFeedCookbook(Feed feed, Cookbook cookbook)
        {
            var feedCookbook = _unitOfWork.FeedCookbook.GetFirstOrDefault(x => x.FeedId == feed.Id && x.CookbookId == cookbook.Id);

            if (feedCookbook != null)
            {
                RemoveFeedCookbook(feedCookbook);
            }
        }
コード例 #9
0
        public void RemoveCookbookRecipe(Cookbook cookbook, Recipe recipe)
        {
            var cookbookRecipe = _unitOfWork.CookbookRecipe.GetFirstOrDefault(x => x.CookbookId == cookbook.Id && x.RecipeId == recipe.Id);

            if (cookbookRecipe != null)
            {
                RemoveCookbookRecipe(cookbookRecipe);
            }
        }
コード例 #10
0
        public async Task RemoveCookbookRecipeAsync(Cookbook cookbook, Recipe recipe)
        {
            var cookbookRecipe = await _unitOfWork.CookbookRecipe.GetFirstOrDefaultAsync(x => x.CookbookId == cookbook.Id && x.RecipeId == recipe.Id);

            if (cookbookRecipe != null)
            {
                RemoveCookbookRecipe(cookbookRecipe);
            }
        }
コード例 #11
0
        public async void TestCookbookGetByUserEager()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <CookingpapaContext>()
                          .UseInMemoryDatabase(databaseName: "Test7DB")
                          .Options;

            //Act
            List <Cookbook> testResultsCookbooks;

            using (var context = new CookingpapaContext(options))
            {
                var _unitOfWork = new UnitOfWork(context);

                var testUser = new User
                {
                    Username = "******",
                    Password = "******",
                    Email    = "*****@*****.**"
                };

                var testRecipe = new Recipe
                {
                };

                var testCookbook = new Cookbook
                {
                    User   = testUser,
                    Recipe = testRecipe
                };

                var testCookbook2 = new Cookbook
                {
                    User   = testUser,
                    Recipe = testRecipe
                };

                await _unitOfWork.Cookbooks.Add(testCookbook);

                await _unitOfWork.Cookbooks.Add(testCookbook2);

                await _unitOfWork.Complete();

                var tempTestCookbooks = await _unitOfWork.Cookbooks.GetByUserEager(1);

                testResultsCookbooks = tempTestCookbooks.ToList();
            }

            //Assert
            using (var context = new CookingpapaContext(options))
            {
                Assert.Equal(1, testResultsCookbooks[0].User.Id);
                Assert.Equal("TestPass", testResultsCookbooks[0].User.Password);
                Assert.Equal(1, testResultsCookbooks[1].User.Id);
                Assert.Equal("TestPass", testResultsCookbooks[1].User.Password);
            }
        }
コード例 #12
0
        public CommunityCookbook AddFromEntities(Community community, Cookbook cookbook)
        {
            var newObj = new CommunityCookbook()
            {
                CommunityId = community.Id,
                CookbookId  = cookbook.Id
            };

            base.Add(newObj);
            return(newObj);
        }
コード例 #13
0
        public ApplicationUserCookbook AddFromEntities(ApplicationUser firstEntity, Cookbook secondEntity)
        {
            ApplicationUserCookbook newObj = new ApplicationUserCookbook()
            {
                ApplicationUserId = firstEntity.Id,
                ObjectId          = secondEntity.Id
            };

            base.Add(newObj);
            return(newObj);
        }
コード例 #14
0
        public async Task <IActionResult> UpdateCookbook(Guid cookbookId, Cookbook model)
        {
            if (cookbookId != model.CookbookId)
            {
                return(BadRequest());
            }

            await _repository.UpdateAsync <Cookbook>(model);

            return(NoContent());
        }
コード例 #15
0
        public OrganizationCookbook AddFromEntities(Organization firstEntity, Cookbook secondEntity)
        {
            var newObj = new OrganizationCookbook()
            {
                OrganizationId = firstEntity.Id,
                CookbookId     = secondEntity.Id
            };

            base.Add(newObj);
            return(newObj);
        }
コード例 #16
0
ファイル: FeedCookbookRepository.cs プロジェクト: rywem/Eyon
        public FeedCookbook AddFromEntities(Feed firstEntity, Cookbook secondEntity)
        {
            var newObj = new FeedCookbook()
            {
                FeedId     = firstEntity.Id,
                CookbookId = secondEntity.Id
            };

            base.Add(newObj);
            return(newObj);
        }
コード例 #17
0
        public CookbookCategory AddFromEntities(Cookbook firstEntity, Category secondEntity)
        {
            var newObj = new CookbookCategory()
            {
                CookbookId = firstEntity.Id,
                CategoryId = secondEntity.Id
            };

            base.Add(newObj);
            return(newObj);
        }
コード例 #18
0
        public async Task <ActionResult <Cookbook> > InsertCookbook(Cookbook model)
        {
            model.CookbookId = Guid.NewGuid();
            var currentTime = DateTime.Now;

            model.CreatedOn  = currentTime;
            model.ModifiedOn = currentTime;
            model.IsActive   = true;
            await _repository.CreateAsync <Cookbook>(model);

            return(CreatedAtAction("GetCookbook", new { cookbookId = model.CookbookId }, model));
        }
コード例 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Reads JSON
            string jsonInput = new System.IO.StreamReader(Context.Request.InputStream, System.Text.Encoding.UTF8).ReadToEnd();

            if (jsonInput != null)
            {
                try
                {
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    js.MaxJsonLength = Int32.MaxValue;
                    //Deserialize json
                    var    time        = js.Deserialize <List <Date2> >(jsonInput);
                    string lastUpdated = time[0].updateTime;                     //gets last updated time from json

                    //Sets up connection
                    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SQLDbConnection"].ConnectionString);

                    //Selects cookbook info from last updated
                    SqlCommand select = new SqlCommand(" SELECT * FROM Cookbook WHERE updateTime > @lastUpdated", con);
                    select.Parameters.AddWithValue("@lastUpdated", lastUpdated);
                    con.Open();

                    //Sets up vars
                    Cookbooks cookbooks = new Cookbooks();
                    cookbooks.Cookbook = new List <Cookbook>();
                    var reader = select.ExecuteReader();
                    while (reader.Read())
                    {
                        //Creates new cookbook object to use for json list
                        byte[]   image    = new byte[0];
                        Cookbook cookbook = new Cookbook();
                        cookbook.name          = (string)reader["name"];
                        cookbook.description   = (string)reader["description"];
                        cookbook.creator       = (string)reader["creator"];
                        cookbook.uniqueid      = (string)reader["uniqueid"];
                        cookbook.privacyOption = (string)reader["privacyOption"];
                        cookbook.progress      = (string)reader["progress"];
                        image          = (byte[])reader["image"];
                        cookbook.image = Convert.ToBase64String(image);
                        cookbooks.Cookbook.Add(cookbook);
                    }
                    con.Close();
                    string json = js.Serialize(cookbooks);                     //serialize list into JSON and then writes it
                    Response.Write(json);
                }catch (Exception ex)
                {
                    Response.Write("Error Selecting Cookbooks");
                    Response.Write(ex);
                }
            }
        }
コード例 #20
0
    public DishSummary(Cookbook cookbook)
    {
        if (cookbook == null)
        {
            throw new ArgumentNullException(nameof(cookbook));
        }

        this.cookbook = cookbook;

        InitializeDishPropertyDictionary();

        matchedRecipeNamesList = new List <Tuple <int, String> >(cookbook.recipes.Count);
    }
コード例 #21
0
        public CookbookViewModel CreateCookbookViewModel(int cookbookId)
        {
            IRepository <Cookbook> cookbooksRepo = _repositoryFactory.CreateRepository <Cookbook>();

            Cookbook cookbook = cookbooksRepo.Get(cookbookId);

            cookbook.OwnerProfile = GetProfile(cookbook.OwnerProfileId);
            cookbook.Recipes      = GetRecipes(cookbookId);

            return(new CookbookViewModel {
                Cookbook = cookbook
            });
        }
コード例 #22
0
ファイル: Day14.cs プロジェクト: jlintvedt/AdventOfCode2018
        public static int Puzzle2(string goalRecipe)
        {
            // Convert input to int array
            var goal = new int[goalRecipe.Length];

            for (int i = 0; i < goalRecipe.Length; i++)
            {
                goal[i] = goalRecipe[i] - '0';
            }

            var cb = new Cookbook(new int[] { 3, 7 });

            return(cb.RecipesNeededToMakeGoalRecipe(goal));
        }
コード例 #23
0
        public async Task <IActionResult> Create([Bind("CookbookId,Name")] Cookbook cookbook)
        {
            if (ModelState.IsValid)
            {
                cookbook.Inserted = DateTime.Now;
                //cookbook.LastUpdated = DateTime.Now;

                _context.Add(cookbook);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(cookbook));
        }
コード例 #24
0
        /// <summary>
        /// We run a cookbook printing business, where amateur chefs send in their favorite home-made
        /// recipes to be printed in self-published family cookbooks.
        /// Many of the steps in our printing press operations for cookbooks are the same,
        /// except for the details of the concrete recipes send in by our clients.  We can leverage a template
        /// method to provide optional virtual hooks and required abstract methods in a base class
        /// that defines our printing algorithm to print specific recipes for the book.
        /// </summary>
        private static void Main()
        {
            var logger = new ConsoleLogger();

            logger.LogInfo("📘 Welcome to the Cookbook Printer");

            var clientRecipes = new List <CookbookRecipe> {
                new CakeRecipe(logger),
                new CurryRecipe(logger)
            };

            var cookbook = new Cookbook(logger, clientRecipes);

            cookbook.Print();
        }
コード例 #25
0
ファイル: Cookbook.cs プロジェクト: MarleneMayr/stonehenge
        private void ApplyArrayChanges(Cookbook cookbook, Recipe[] newArray)
        {
            cookbook.recipes = newArray;
            // apply overrides if prefab instance was edited
            if (PrefabUtility.IsPartOfAnyPrefab(cookbook))
            {
                PrefabUtility.ApplyPrefabInstance(cookbook.gameObject, InteractionMode.UserAction);
            }

            // apply changes if prefab was edited in prefab scene
            var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();

            if (prefabStage != null)
            {
                EditorSceneManager.MarkSceneDirty(prefabStage.scene);
            }
        }
コード例 #26
0
ファイル: BusinessL.cs プロジェクト: kenendo12/Team1-repo2
        /// <summary>
        /// Saves a recipe into a user cookbook.
        /// If the recipe already exist in the cook book, the checkIfExists will return an instance of
        /// Cookbook and return null/error to the user.
        /// </summary>
        /// <param name="cookbook">includes user Id and recipe Id to save to cookbook</param>
        /// <returns></returns>
        public async Task <Cookbook> PostCookbook(PostCookbookVM cookbook)
        {
            var checkIfExists = _unitOfWork.Cookbooks.GetByUserEager(cookbook.UserId)
                                .Result.ToList().Find(x => x.Recipe.Id == cookbook.RecipeId);

            if (checkIfExists == null)
            {
                var newCookbook = new Cookbook();
                newCookbook.User = await _unitOfWork.Users.Get(cookbook.UserId);

                newCookbook.Recipe = await _unitOfWork.Recipes.GetEager(cookbook.RecipeId);

                _unitOfWork.Cookbooks.Add(newCookbook);
                await _unitOfWork.Complete();

                return(newCookbook);
            }
            return(null);
        }
コード例 #27
0
        public async void TestCookbookDelete()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <CookingpapaContext>()
                          .UseInMemoryDatabase(databaseName: "Test5DB")
                          .Options;

            //Act
            List <Cookbook> cookbookElements;

            using (var context = new CookingpapaContext(options))
            {
                var _unitOfWork = new UnitOfWork(context);

                var testCookbook = new Cookbook
                {
                };

                await _unitOfWork.Cookbooks.Add(testCookbook);

                await _unitOfWork.Complete();

                _unitOfWork.Cookbooks.Delete(1);
                await _unitOfWork.Complete();

                var tempTestOrigins = await _unitOfWork.Cookbooks.GetAll();

                cookbookElements = tempTestOrigins.ToList();
            }

            //Assert
            using (var context = new CookingpapaContext(options))
            {
                Assert.Empty(cookbookElements);
            }
        }
コード例 #28
0
 public CookbookRecipe AddCookbookRecipe(Cookbook cookbook, Recipe recipe)
 {
     return(_unitOfWork.CookbookRecipe.AddFromEntities(cookbook, recipe));
 }
コード例 #29
0
 public IActionResult OnPost(Cookbook cookbook)
 {
     Cookbook = _cookbooksRepo.Insert(cookbook);
     return(RedirectToPage("../Users/Cookbooks", new { userId = Cookbook.UserId }));
 }
コード例 #30
0
 public IActionResult OnPost(Cookbook cookbook)
 {
     Cookbook = _cookbooksRepo.Update(cookbook);
     return(RedirectToPage("Cookbooks", new { userId = Cookbook.UserId }));
 }