Exemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            recipe         = (Recipe)e.Parameter;
            journalEntries = recipe.JournalEntries;
        }
        public static RecipeJournal getJournalEntries(long recipeId)
        {
            RecipeJournal    savedjournalEntries = new RecipeJournal();
            SqliteConnection db = new SqliteConnection("Filename=RecipeBook.db");

            db.Open();

            SqliteCommand selectCommand = new SqliteCommand("SELECT * from JOURNAL_ENTRIES WHERE RID = @RecipeID");

            selectCommand.Connection = db;
            selectCommand.Parameters.AddWithValue("@RecipeID", recipeId);
            SqliteDataReader query = selectCommand.ExecuteReader();

            while (query.Read())
            {
                long               id         = query.GetInt64(0);
                String             entryNotes = query.GetString(2);
                double             rating     = query.GetDouble(3);
                DateTime           entryDate  = query.GetDateTime(4);
                RecipeJournalEntry savedEntry = new RecipeJournalEntry(id);
                savedEntry.RecipeID   = recipeId;
                savedEntry.EntryDate  = entryDate;
                savedEntry.EntryNotes = entryNotes;
                savedEntry.Rating     = rating;
                savedjournalEntries.Add(savedEntry);
            }

            db.Close();
            Debug.WriteLine("Saved Entries: " + savedjournalEntries.getSize());
            return(savedjournalEntries);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            recipes          = new RecipeList();

            recipes.verifyImageFolder();

            RecipeBookDataAccessor.InitializeDatabase();

            long recipeStartingId = RecipeBookDataAccessor.getMaxId(Recipe.TABLE_NAME) + 1;

            RecipeList.recipeIdGenerator = new IdentifierGenerator(Recipe.TABLE_NAME, recipeStartingId);

            long ingredientStartingId = RecipeBookDataAccessor.getMaxId(RecipeIngredient.TABLE_NAME) + 1;

            RecipeList.ingredientIdGenerator = new IdentifierGenerator(RecipeIngredient.TABLE_NAME, ingredientStartingId);

            long stepStartingId = RecipeBookDataAccessor.getMaxId(RecipeStep.TABLE_NAME) + 1;

            RecipeList.stepIdGenerator = new IdentifierGenerator(RecipeStep.TABLE_NAME, stepStartingId);

            long imageStartingId = RecipeBookDataAccessor.getMaxId(RecipeImage.TABLE_NAME) + 1;

            RecipeList.imageIdGenerator = new IdentifierGenerator(RecipeImage.TABLE_NAME, imageStartingId);

            long entryStartingId = RecipeBookDataAccessor.getMaxId(RecipeJournalEntry.TABLE_NAME) + 1;

            RecipeList.journalEntryIdGenerator = new IdentifierGenerator(RecipeJournalEntry.TABLE_NAME, entryStartingId);

            ObservableCollection <Recipe> savedRecipes = RecipeBookDataAccessor.getSavedRecipes();

            for (int i = 0; i < savedRecipes.Count; i++)
            {
                Recipe savedRecipe = savedRecipes[i];
                ObservableCollection <RecipeIngredient> savedIngredients = RecipeBookDataAccessor.getIngredients(savedRecipe.ID);
                ObservableCollection <RecipeStep>       savedSteps       = RecipeBookDataAccessor.getSteps(savedRecipe.ID);
                ObservableCollection <RecipeImage>      savedImages      = RecipeBookDataAccessor.getImages(savedRecipe.ID);
                RecipeJournal savedEntries = RecipeBookDataAccessor.getJournalEntries(savedRecipe.ID);
                savedRecipe.setIngredients(savedIngredients);
                savedRecipe.setSteps(savedSteps);
                savedRecipe.setImages(savedImages);
                savedRecipe.setJournalEntries(savedEntries);
            }
            recipes.setRecipeList(savedRecipes);
        }
Exemplo n.º 4
0
        public RecipeJournal GetRecipeJournal(string executionId)
        {
            var executionJournal = GetJournalFile(executionId);
            var xElement         = XElement.Parse(ReadJournal(executionJournal));

            var journal = new RecipeJournal {
                ExecutionId = executionId
            };
            var messages = new List <JournalMessage>();

            journal.Status = ReadStatusFromJournal(xElement);
            foreach (var message in xElement.Elements("Message"))
            {
                messages.Add(new JournalMessage {
                    Message = message.Value
                });
            }
            journal.Messages = messages;

            return(journal);
        }