using Microsoft.AspNetCore.Html; using System; using System.Net; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Office.Interop.Word; using static System.Net.WebRequestMethods; namespace JRCookbookBusiness { public class Recipe : ICloneable { public Guid? recipeID = null; public Guid? cookbookID = null; public Guid? cookbookchapterID = null; public String recipename = String.Empty; public String author = String.Empty; public String source = String.Empty; public String webpage = String.Empty; public String comments = String.Empty; public String copyright = String.Empty; public Single servings = 0; public String nutritionservinglabel = String.Empty; public String yield = String.Empty; public Int32 preparationtime = 0; public Int32 cookingtime = 0; public Int32 readyintime = 0; public Int32 inactivetime = 0; public Int16 oventemperaturec = 0; public Int16 oventemperaturef = 0; public Single percentcaloriesfromalcohol = 0; public Single percentcaloriesfromcarbs = 0; public Single percentcaloriesfromfat = 0; public Single percentcaloriesfromprotein = 0; public Single alanine = 0; public Single alcohol = 0; public Single alcoholfactor = 0; public Single alphacarotene = 0; public Single alphalinolenicacid = 0; public Single arachidonicacid = 0; public Single arginine = 0; public Single ash = 0; public Single asparticacid = 0; public Single betacarotene = 0; public Single betacryptoxanthin = 0; public Single betasitosterol = 0; public Single betatocopherol = 0; public Single biotin = 0; public Single caffeine = 0; public Single calcium = 0; public Single calories = 0; public Single caloriesfromalcohol = 0; public Single caloriesfromcarbs = 0; public Single caloriesfromfat = 0; public Single caloriesfromprotein = 0; public Single campesterol = 0; public Single carbohydratefactor = 0; public Single chloride = 0; public Single cholesterol = 0; public Single choline = 0; public Single chromium = 0; public Single copper = 0; public Single cystine = 0; public Single deltatocopherol = 0; public Single dihomogammalinolenicacid = 0; public Single docosahexaenoicacid = 0; public Single docosapentaenoicacid = 0; public Single eicosadienoicacid = 0; public Single eicosapentaenoicacid = 0; public Single energy = 0; public Single energyfromalcohol = 0; public Single energyfromcarbs = 0; public Single energyfromfat = 0; public Single energyfromprotein = 0; public Single fatfactor = 0; public Single fiber = 0; public Single fluoride = 0; public Single folate = 0; public Single fructose = 0; public Single galactose = 0; public Single gammalinolenicacid = 0; public Single gammatocopherol = 0; public Single glucose = 0; public Single glutamicacid = 0; public Single glycine = 0; public Single histidine = 0; public Single hydroxyproline = 0; public Single iodine = 0; public Single iron = 0; public Single isoleucine = 0; public Single lactose = 0; public Single leucine = 0; public Single linoleicacid = 0; public Single lycopene = 0; public Single lysine = 0; public Single magnesium = 0; public Single maltose = 0; public Single manganese = 0; public Single mass = 0; public Single methionine = 0; public Single molybdenum = 0; public Single monounsaturatedfat = 0; public Single monounsaturatedfattyacid_14_1 = 0; public Single monounsaturatedfattyacid_15_1 = 0; public Single monounsaturatedfattyacid_16_1 = 0; public Single monounsaturatedfattyacid_17_1 = 0; public Single monounsaturatedfattyacid_18_1 = 0; public Single monounsaturatedfattyacid_20_1 = 0; public Single monounsaturatedfattyacid_22_1 = 0; public Single monounsaturatedfattyacid_24_1 = 0; public Single netcarbohydrates = 0; public Single niacin = 0; public Single omega3fattyacids = 0; public Single omega6fattyacids = 0; public Single pantothenicacid = 0; public Single phenylalanine = 0; public Single phosphorus = 0; public Single phytosterols = 0; public Single polyunsaturatedfat = 0; public Single polyunsaturatedfattyacid_18_2 = 0; public Single polyunsaturatedfattyacid_18_3 = 0; public Single polyunsaturatedfattyacid_18_4 = 0; public Single polyunsaturatedfattyacid_20_3 = 0; public Single polyunsaturatedfattyacid_20_4 = 0; public Single polyunsaturatedfattyacid_21_5 = 0; public Single polyunsaturatedfattyacid_22_4 = 0; public Single potassium = 0; public Single proline = 0; public Single protein = 0; public Single proteinfactor = 0; public Single refuse = 0; public Single retinol = 0; public Single riboflavin = 0; public Single saturatedfat = 0; public Single saturatedfattyacid_10_0 = 0; public Single saturatedfattyacid_12_0 = 0; public Single saturatedfattyacid_13_0 = 0; public Single saturatedfattyacid_14_0 = 0; public Single saturatedfattyacid_15_0 = 0; public Single saturatedfattyacid_16_0 = 0; public Single saturatedfattyacid_17_0 = 0; public Single saturatedfattyacid_18_0 = 0; public Single saturatedfattyacid_20_0 = 0; public Single saturatedfattyacid_22_0 = 0; public Single saturatedfattyacid_24_0 = 0; public Single saturatedfattyacid_4_0 = 0; public Single saturatedfattyacid_6_0 = 0; public Single saturatedfattyacid_8_0 = 0; public Single selenium = 0; public Single serine = 0; public Single sodium = 0; public Single starch = 0; public Single stigmasterol = 0; public Single sucrose = 0; public Single sugar = 0; public Single sugaralcohols = 0; public Single theobromine = 0; public Single thiamin = 0; public Single threonine = 0; public Single totalcarbohydrate = 0; public Single totalfat = 0; public Single transfattyacids = 0; public Single transmonoenoicfattyacids = 0; public Single transpolyenoicfattyacids = 0; public Single tryptophan = 0; public Single tyrosine = 0; public Single valine = 0; public Single vitamina = 0; public Single vitaminb12 = 0; public Single vitaminb6 = 0; public Single vitaminc = 0; public Single vitamind = 0; public Single vitamine = 0; public Single vitamink = 0; public Single volume = 0; public Single water = 0; public Single zinc = 0; public List recipeIngredients = new List(); public List recipeProcedures = new List(); public List recipeTips = new List(); public event EventHandler RecipeRenderedEvent; public Recipe() { } public Recipe(Guid recipeID) { PopulateByID(recipeID); } public void PasteIntoChapter(Guid newCookbookID, Guid? newCookbookChapterID) { this.recipeID = null; this.cookbookID = newCookbookID; this.cookbookchapterID = newCookbookChapterID; foreach (var recipeIngredient in this.recipeIngredients) { recipeIngredient.recipeIngredientID = null; } foreach (var recipeProcedure in this.recipeProcedures) { recipeProcedure.recipeProcedureID = null; } foreach (var recipeTip in this.recipeTips) { recipeTip.recipeTipID = null; } this.Save(); } public void Save() { this.CalcNutrition(); if (this.recipeID == null) { this.recipeID = clsDatabaseLayer.GetDatabaseLayer().GetNewIDRecipe(); clsDatabaseLayer.GetDatabaseLayer().InsertRecipe(this); } else { clsDatabaseLayer.GetDatabaseLayer().UpdateRecipe(this); } var recipeIngredientIndex = 0; var procedureIndex = 0; var tipIndex = 0; RecipeIngredient.DeleteAllByRecipeID(recipeID.Value); foreach (var recipeIngredient in this.recipeIngredients) { recipeIngredient.recipeIngredientID = null; recipeIngredient.recipeID = this.recipeID; recipeIngredient.ingredientIndex = recipeIngredientIndex; recipeIngredient.Save(); recipeIngredientIndex += 1; } RecipeProcedure.DeleteAllByRecipeID(recipeID.Value); foreach (var recipeProcedure in this.recipeProcedures) { recipeProcedure.recipeProcedureID = null; recipeProcedure.recipeID = this.recipeID; recipeProcedure.procedureIndex = procedureIndex; recipeProcedure.Save(); procedureIndex += 1; } RecipeTip.DeleteAllByRecipeID(recipeID.Value); foreach (var recipeTip in this.recipeTips) { recipeTip.recipeTipID = null; recipeTip.recipeID = this.recipeID; recipeTip.tipIndex = tipIndex; recipeTip.Save(); tipIndex += 1; } } public void Delete() { RecipeIngredient.DeleteAllByRecipeID(recipeID.Value); RecipeProcedure.DeleteAllByRecipeID(recipeID.Value); RecipeTip.DeleteAllByRecipeID(recipeID.Value); clsDatabaseLayer.GetDatabaseLayer().DeleteRecipeByID(recipeID.Value); } internal void GenerateWebPageToFolder(String folderToSaveTo, Dictionary recipePageDictionary, SortedList recipesAlpha, SortedSet pagesAlreadyAdded, List trackbackList) { var recipeHTML = this.GetHTML(trackbackList); String pageNameToUse = SharedRoutines.RemoveSpecialCharactersFromFileName(this.recipename); String pageNameToUseWithExtension = pageNameToUse + ".htm"; while(pagesAlreadyAdded.Contains(pageNameToUseWithExtension.ToUpper())) { pageNameToUse += "1"; pageNameToUseWithExtension = pageNameToUse + ".htm"; } recipePageDictionary.Add(this.recipeID.Value, pageNameToUseWithExtension); recipesAlpha.Add(this.recipename.ToUpper(), this); pagesAlreadyAdded.Add(pageNameToUseWithExtension.ToUpper()); var strRecipePath = folderToSaveTo; if (strRecipePath.EndsWith("\\") == false) { strRecipePath += "\\"; } strRecipePath += pageNameToUseWithExtension; using (var writer = new System.IO.StreamWriter(strRecipePath, false)) { writer.Write(recipeHTML); } if (RecipeRenderedEvent != null) { RecipeRenderedEvent.Invoke(this, new EventArgs()); } } public static Recipe GetRecipeByID(Guid recipeID) { return new Recipe(recipeID); } public static void DeleteByID(Guid recipeID) { var recipe = new Recipe(recipeID); recipe.Delete(); } private void PopulateByID(Guid recipeID) { DataSet recordSet; recordSet = clsDatabaseLayer.GetDatabaseLayer().GetRecipeByID(recipeID); if (recordSet.Tables[0].Rows.Count > 0) { DataRow ldbrwRow; ldbrwRow = recordSet.Tables[0].Rows[0]; PopulateFromDataRow(ldbrwRow); } } private void PopulateFromDataRow(DataRow dataRow) { InitializeAllFields(); if (dataRow.IsNull("recipeID")) recipeID = null; else recipeID = (Guid)dataRow["recipeID"]; if (dataRow.IsNull("cookbookID")) cookbookID = null; else cookbookID = (Guid)dataRow["cookbookID"]; if (dataRow.IsNull("cookbookchapterID")) cookbookchapterID = null; else cookbookchapterID = (Guid)dataRow["cookbookchapterID"]; if (dataRow.IsNull("recipename")) recipename = String.Empty; else recipename = (String)dataRow["recipename"]; if (dataRow.IsNull("author")) author = String.Empty; else author = (String)dataRow["author"]; if (dataRow.IsNull("source")) source = String.Empty; else source = (String)dataRow["source"]; if (dataRow.IsNull("webpage")) webpage = String.Empty; else webpage = (String)dataRow["webpage"]; if (dataRow.IsNull("comments")) comments = String.Empty; else comments = (String)dataRow["comments"]; if (dataRow.IsNull("copyright")) copyright = String.Empty; else copyright = (String)dataRow["copyright"]; if (dataRow.IsNull("servings")) servings = 0; else servings = (Single)dataRow["servings"]; if (dataRow.IsNull("nutritionservinglabel")) nutritionservinglabel = String.Empty; else nutritionservinglabel = (String)dataRow["nutritionservinglabel"]; if (dataRow.IsNull("yield")) yield = String.Empty; else yield = (String)dataRow["yield"]; if (dataRow.IsNull("preparationtime")) preparationtime = 0; else preparationtime = (Int32)dataRow["preparationtime"]; if (dataRow.IsNull("cookingtime")) cookingtime = 0; else cookingtime = (Int32)dataRow["cookingtime"]; if (dataRow.IsNull("readyintime")) readyintime = 0; else readyintime = (Int32)dataRow["readyintime"]; if (dataRow.IsNull("inactivetime")) inactivetime = 0; else inactivetime = (Int32)dataRow["inactivetime"]; if (dataRow.IsNull("oventemperaturec")) oventemperaturec = 0; else oventemperaturec = (Int16)dataRow["oventemperaturec"]; if (dataRow.IsNull("oventemperaturef")) oventemperaturef = 0; else oventemperaturef = (Int16)dataRow["oventemperaturef"]; if (dataRow.IsNull("percentcaloriesfromalcohol")) percentcaloriesfromalcohol = 0; else percentcaloriesfromalcohol = (Single)dataRow["percentcaloriesfromalcohol"]; if (dataRow.IsNull("percentcaloriesfromcarbs")) percentcaloriesfromcarbs = 0; else percentcaloriesfromcarbs = (Single)dataRow["percentcaloriesfromcarbs"]; if (dataRow.IsNull("percentcaloriesfromfat")) percentcaloriesfromfat = 0; else percentcaloriesfromfat = (Single)dataRow["percentcaloriesfromfat"]; if (dataRow.IsNull("percentcaloriesfromprotein")) percentcaloriesfromprotein = 0; else percentcaloriesfromprotein = (Single)dataRow["percentcaloriesfromprotein"]; if (dataRow.IsNull("alanine")) alanine = 0; else alanine = (Single)dataRow["alanine"]; if (dataRow.IsNull("alcohol")) alcohol = 0; else alcohol = (Single)dataRow["alcohol"]; if (dataRow.IsNull("alcoholfactor")) alcoholfactor = 0; else alcoholfactor = (Single)dataRow["alcoholfactor"]; if (dataRow.IsNull("alphacarotene")) alphacarotene = 0; else alphacarotene = (Single)dataRow["alphacarotene"]; if (dataRow.IsNull("alphalinolenicacid")) alphalinolenicacid = 0; else alphalinolenicacid = (Single)dataRow["alphalinolenicacid"]; if (dataRow.IsNull("arachidonicacid")) arachidonicacid = 0; else arachidonicacid = (Single)dataRow["arachidonicacid"]; if (dataRow.IsNull("arginine")) arginine = 0; else arginine = (Single)dataRow["arginine"]; if (dataRow.IsNull("ash")) ash = 0; else ash = (Single)dataRow["ash"]; if (dataRow.IsNull("asparticacid")) asparticacid = 0; else asparticacid = (Single)dataRow["asparticacid"]; if (dataRow.IsNull("betacarotene")) betacarotene = 0; else betacarotene = (Single)dataRow["betacarotene"]; if (dataRow.IsNull("betacryptoxanthin")) betacryptoxanthin = 0; else betacryptoxanthin = (Single)dataRow["betacryptoxanthin"]; if (dataRow.IsNull("betasitosterol")) betasitosterol = 0; else betasitosterol = (Single)dataRow["betasitosterol"]; if (dataRow.IsNull("betatocopherol")) betatocopherol = 0; else betatocopherol = (Single)dataRow["betatocopherol"]; if (dataRow.IsNull("biotin")) biotin = 0; else biotin = (Single)dataRow["biotin"]; if (dataRow.IsNull("caffeine")) caffeine = 0; else caffeine = (Single)dataRow["caffeine"]; if (dataRow.IsNull("calcium")) calcium = 0; else calcium = (Single)dataRow["calcium"]; if (dataRow.IsNull("calories")) calories = 0; else calories = (Single)dataRow["calories"]; if (dataRow.IsNull("caloriesfromalcohol")) caloriesfromalcohol = 0; else caloriesfromalcohol = (Single)dataRow["caloriesfromalcohol"]; if (dataRow.IsNull("caloriesfromcarbs")) caloriesfromcarbs = 0; else caloriesfromcarbs = (Single)dataRow["caloriesfromcarbs"]; if (dataRow.IsNull("caloriesfromfat")) caloriesfromfat = 0; else caloriesfromfat = (Single)dataRow["caloriesfromfat"]; if (dataRow.IsNull("caloriesfromprotein")) caloriesfromprotein = 0; else caloriesfromprotein = (Single)dataRow["caloriesfromprotein"]; if (dataRow.IsNull("campesterol")) campesterol = 0; else campesterol = (Single)dataRow["campesterol"]; if (dataRow.IsNull("carbohydratefactor")) carbohydratefactor = 0; else carbohydratefactor = (Single)dataRow["carbohydratefactor"]; if (dataRow.IsNull("chloride")) chloride = 0; else chloride = (Single)dataRow["chloride"]; if (dataRow.IsNull("cholesterol")) cholesterol = 0; else cholesterol = (Single)dataRow["cholesterol"]; if (dataRow.IsNull("choline")) choline = 0; else choline = (Single)dataRow["choline"]; if (dataRow.IsNull("chromium")) chromium = 0; else chromium = (Single)dataRow["chromium"]; if (dataRow.IsNull("copper")) copper = 0; else copper = (Single)dataRow["copper"]; if (dataRow.IsNull("cystine")) cystine = 0; else cystine = (Single)dataRow["cystine"]; if (dataRow.IsNull("deltatocopherol")) deltatocopherol = 0; else deltatocopherol = (Single)dataRow["deltatocopherol"]; if (dataRow.IsNull("dihomogammalinolenicacid")) dihomogammalinolenicacid = 0; else dihomogammalinolenicacid = (Single)dataRow["dihomogammalinolenicacid"]; if (dataRow.IsNull("docosahexaenoicacid")) docosahexaenoicacid = 0; else docosahexaenoicacid = (Single)dataRow["docosahexaenoicacid"]; if (dataRow.IsNull("docosapentaenoicacid")) docosapentaenoicacid = 0; else docosapentaenoicacid = (Single)dataRow["docosapentaenoicacid"]; if (dataRow.IsNull("eicosadienoicacid")) eicosadienoicacid = 0; else eicosadienoicacid = (Single)dataRow["eicosadienoicacid"]; if (dataRow.IsNull("eicosapentaenoicacid")) eicosapentaenoicacid = 0; else eicosapentaenoicacid = (Single)dataRow["eicosapentaenoicacid"]; if (dataRow.IsNull("energy")) energy = 0; else energy = (Single)dataRow["energy"]; if (dataRow.IsNull("energyfromalcohol")) energyfromalcohol = 0; else energyfromalcohol = (Single)dataRow["energyfromalcohol"]; if (dataRow.IsNull("energyfromcarbs")) energyfromcarbs = 0; else energyfromcarbs = (Single)dataRow["energyfromcarbs"]; if (dataRow.IsNull("energyfromfat")) energyfromfat = 0; else energyfromfat = (Single)dataRow["energyfromfat"]; if (dataRow.IsNull("energyfromprotein")) energyfromprotein = 0; else energyfromprotein = (Single)dataRow["energyfromprotein"]; if (dataRow.IsNull("fatfactor")) fatfactor = 0; else fatfactor = (Single)dataRow["fatfactor"]; if (dataRow.IsNull("fiber")) fiber = 0; else fiber = (Single)dataRow["fiber"]; if (dataRow.IsNull("fluoride")) fluoride = 0; else fluoride = (Single)dataRow["fluoride"]; if (dataRow.IsNull("folate")) folate = 0; else folate = (Single)dataRow["folate"]; if (dataRow.IsNull("fructose")) fructose = 0; else fructose = (Single)dataRow["fructose"]; if (dataRow.IsNull("galactose")) galactose = 0; else galactose = (Single)dataRow["galactose"]; if (dataRow.IsNull("gammalinolenicacid")) gammalinolenicacid = 0; else gammalinolenicacid = (Single)dataRow["gammalinolenicacid"]; if (dataRow.IsNull("gammatocopherol")) gammatocopherol = 0; else gammatocopherol = (Single)dataRow["gammatocopherol"]; if (dataRow.IsNull("glucose")) glucose = 0; else glucose = (Single)dataRow["glucose"]; if (dataRow.IsNull("glutamicacid")) glutamicacid = 0; else glutamicacid = (Single)dataRow["glutamicacid"]; if (dataRow.IsNull("glycine")) glycine = 0; else glycine = (Single)dataRow["glycine"]; if (dataRow.IsNull("histidine")) histidine = 0; else histidine = (Single)dataRow["histidine"]; if (dataRow.IsNull("hydroxyproline")) hydroxyproline = 0; else hydroxyproline = (Single)dataRow["hydroxyproline"]; if (dataRow.IsNull("iodine")) iodine = 0; else iodine = (Single)dataRow["iodine"]; if (dataRow.IsNull("iron")) iron = 0; else iron = (Single)dataRow["iron"]; if (dataRow.IsNull("isoleucine")) isoleucine = 0; else isoleucine = (Single)dataRow["isoleucine"]; if (dataRow.IsNull("lactose")) lactose = 0; else lactose = (Single)dataRow["lactose"]; if (dataRow.IsNull("leucine")) leucine = 0; else leucine = (Single)dataRow["leucine"]; if (dataRow.IsNull("linoleicacid")) linoleicacid = 0; else linoleicacid = (Single)dataRow["linoleicacid"]; if (dataRow.IsNull("lycopene")) lycopene = 0; else lycopene = (Single)dataRow["lycopene"]; if (dataRow.IsNull("lysine")) lysine = 0; else lysine = (Single)dataRow["lysine"]; if (dataRow.IsNull("magnesium")) magnesium = 0; else magnesium = (Single)dataRow["magnesium"]; if (dataRow.IsNull("maltose")) maltose = 0; else maltose = (Single)dataRow["maltose"]; if (dataRow.IsNull("manganese")) manganese = 0; else manganese = (Single)dataRow["manganese"]; if (dataRow.IsNull("mass")) mass = 0; else mass = (Single)dataRow["mass"]; if (dataRow.IsNull("methionine")) methionine = 0; else methionine = (Single)dataRow["methionine"]; if (dataRow.IsNull("molybdenum")) molybdenum = 0; else molybdenum = (Single)dataRow["molybdenum"]; if (dataRow.IsNull("monounsaturatedfat")) monounsaturatedfat = 0; else monounsaturatedfat = (Single)dataRow["monounsaturatedfat"]; if (dataRow.IsNull("monounsaturatedfattyacid_14_1")) monounsaturatedfattyacid_14_1 = 0; else monounsaturatedfattyacid_14_1 = (Single)dataRow["monounsaturatedfattyacid_14_1"]; if (dataRow.IsNull("monounsaturatedfattyacid_15_1")) monounsaturatedfattyacid_15_1 = 0; else monounsaturatedfattyacid_15_1 = (Single)dataRow["monounsaturatedfattyacid_15_1"]; if (dataRow.IsNull("monounsaturatedfattyacid_16_1")) monounsaturatedfattyacid_16_1 = 0; else monounsaturatedfattyacid_16_1 = (Single)dataRow["monounsaturatedfattyacid_16_1"]; if (dataRow.IsNull("monounsaturatedfattyacid_17_1")) monounsaturatedfattyacid_17_1 = 0; else monounsaturatedfattyacid_17_1 = (Single)dataRow["monounsaturatedfattyacid_17_1"]; if (dataRow.IsNull("monounsaturatedfattyacid_18_1")) monounsaturatedfattyacid_18_1 = 0; else monounsaturatedfattyacid_18_1 = (Single)dataRow["monounsaturatedfattyacid_18_1"]; if (dataRow.IsNull("monounsaturatedfattyacid_20_1")) monounsaturatedfattyacid_20_1 = 0; else monounsaturatedfattyacid_20_1 = (Single)dataRow["monounsaturatedfattyacid_20_1"]; if (dataRow.IsNull("monounsaturatedfattyacid_22_1")) monounsaturatedfattyacid_22_1 = 0; else monounsaturatedfattyacid_22_1 = (Single)dataRow["monounsaturatedfattyacid_22_1"]; if (dataRow.IsNull("monounsaturatedfattyacid_24_1")) monounsaturatedfattyacid_24_1 = 0; else monounsaturatedfattyacid_24_1 = (Single)dataRow["monounsaturatedfattyacid_24_1"]; if (dataRow.IsNull("netcarbohydrates")) netcarbohydrates = 0; else netcarbohydrates = (Single)dataRow["netcarbohydrates"]; if (dataRow.IsNull("niacin")) niacin = 0; else niacin = (Single)dataRow["niacin"]; if (dataRow.IsNull("omega3fattyacids")) omega3fattyacids = 0; else omega3fattyacids = (Single)dataRow["omega3fattyacids"]; if (dataRow.IsNull("omega6fattyacids")) omega6fattyacids = 0; else omega6fattyacids = (Single)dataRow["omega6fattyacids"]; if (dataRow.IsNull("pantothenicacid")) pantothenicacid = 0; else pantothenicacid = (Single)dataRow["pantothenicacid"]; if (dataRow.IsNull("phenylalanine")) phenylalanine = 0; else phenylalanine = (Single)dataRow["phenylalanine"]; if (dataRow.IsNull("phosphorus")) phosphorus = 0; else phosphorus = (Single)dataRow["phosphorus"]; if (dataRow.IsNull("phytosterols")) phytosterols = 0; else phytosterols = (Single)dataRow["phytosterols"]; if (dataRow.IsNull("polyunsaturatedfat")) polyunsaturatedfat = 0; else polyunsaturatedfat = (Single)dataRow["polyunsaturatedfat"]; if (dataRow.IsNull("polyunsaturatedfattyacid_18_2")) polyunsaturatedfattyacid_18_2 = 0; else polyunsaturatedfattyacid_18_2 = (Single)dataRow["polyunsaturatedfattyacid_18_2"]; if (dataRow.IsNull("polyunsaturatedfattyacid_18_3")) polyunsaturatedfattyacid_18_3 = 0; else polyunsaturatedfattyacid_18_3 = (Single)dataRow["polyunsaturatedfattyacid_18_3"]; if (dataRow.IsNull("polyunsaturatedfattyacid_18_4")) polyunsaturatedfattyacid_18_4 = 0; else polyunsaturatedfattyacid_18_4 = (Single)dataRow["polyunsaturatedfattyacid_18_4"]; if (dataRow.IsNull("polyunsaturatedfattyacid_20_3")) polyunsaturatedfattyacid_20_3 = 0; else polyunsaturatedfattyacid_20_3 = (Single)dataRow["polyunsaturatedfattyacid_20_3"]; if (dataRow.IsNull("polyunsaturatedfattyacid_20_4")) polyunsaturatedfattyacid_20_4 = 0; else polyunsaturatedfattyacid_20_4 = (Single)dataRow["polyunsaturatedfattyacid_20_4"]; if (dataRow.IsNull("polyunsaturatedfattyacid_21_5")) polyunsaturatedfattyacid_21_5 = 0; else polyunsaturatedfattyacid_21_5 = (Single)dataRow["polyunsaturatedfattyacid_21_5"]; if (dataRow.IsNull("polyunsaturatedfattyacid_22_4")) polyunsaturatedfattyacid_22_4 = 0; else polyunsaturatedfattyacid_22_4 = (Single)dataRow["polyunsaturatedfattyacid_22_4"]; if (dataRow.IsNull("potassium")) potassium = 0; else potassium = (Single)dataRow["potassium"]; if (dataRow.IsNull("proline")) proline = 0; else proline = (Single)dataRow["proline"]; if (dataRow.IsNull("protein")) protein = 0; else protein = (Single)dataRow["protein"]; if (dataRow.IsNull("proteinfactor")) proteinfactor = 0; else proteinfactor = (Single)dataRow["proteinfactor"]; if (dataRow.IsNull("refuse")) refuse = 0; else refuse = (Single)dataRow["refuse"]; if (dataRow.IsNull("retinol")) retinol = 0; else retinol = (Single)dataRow["retinol"]; if (dataRow.IsNull("riboflavin")) riboflavin = 0; else riboflavin = (Single)dataRow["riboflavin"]; if (dataRow.IsNull("saturatedfat")) saturatedfat = 0; else saturatedfat = (Single)dataRow["saturatedfat"]; if (dataRow.IsNull("saturatedfattyacid_10_0")) saturatedfattyacid_10_0 = 0; else saturatedfattyacid_10_0 = (Single)dataRow["saturatedfattyacid_10_0"]; if (dataRow.IsNull("saturatedfattyacid_12_0")) saturatedfattyacid_12_0 = 0; else saturatedfattyacid_12_0 = (Single)dataRow["saturatedfattyacid_12_0"]; if (dataRow.IsNull("saturatedfattyacid_13_0")) saturatedfattyacid_13_0 = 0; else saturatedfattyacid_13_0 = (Single)dataRow["saturatedfattyacid_13_0"]; if (dataRow.IsNull("saturatedfattyacid_14_0")) saturatedfattyacid_14_0 = 0; else saturatedfattyacid_14_0 = (Single)dataRow["saturatedfattyacid_14_0"]; if (dataRow.IsNull("saturatedfattyacid_15_0")) saturatedfattyacid_15_0 = 0; else saturatedfattyacid_15_0 = (Single)dataRow["saturatedfattyacid_15_0"]; if (dataRow.IsNull("saturatedfattyacid_16_0")) saturatedfattyacid_16_0 = 0; else saturatedfattyacid_16_0 = (Single)dataRow["saturatedfattyacid_16_0"]; if (dataRow.IsNull("saturatedfattyacid_17_0")) saturatedfattyacid_17_0 = 0; else saturatedfattyacid_17_0 = (Single)dataRow["saturatedfattyacid_17_0"]; if (dataRow.IsNull("saturatedfattyacid_18_0")) saturatedfattyacid_18_0 = 0; else saturatedfattyacid_18_0 = (Single)dataRow["saturatedfattyacid_18_0"]; if (dataRow.IsNull("saturatedfattyacid_20_0")) saturatedfattyacid_20_0 = 0; else saturatedfattyacid_20_0 = (Single)dataRow["saturatedfattyacid_20_0"]; if (dataRow.IsNull("saturatedfattyacid_22_0")) saturatedfattyacid_22_0 = 0; else saturatedfattyacid_22_0 = (Single)dataRow["saturatedfattyacid_22_0"]; if (dataRow.IsNull("saturatedfattyacid_24_0")) saturatedfattyacid_24_0 = 0; else saturatedfattyacid_24_0 = (Single)dataRow["saturatedfattyacid_24_0"]; if (dataRow.IsNull("saturatedfattyacid_4_0")) saturatedfattyacid_4_0 = 0; else saturatedfattyacid_4_0 = (Single)dataRow["saturatedfattyacid_4_0"]; if (dataRow.IsNull("saturatedfattyacid_6_0")) saturatedfattyacid_6_0 = 0; else saturatedfattyacid_6_0 = (Single)dataRow["saturatedfattyacid_6_0"]; if (dataRow.IsNull("saturatedfattyacid_8_0")) saturatedfattyacid_8_0 = 0; else saturatedfattyacid_8_0 = (Single)dataRow["saturatedfattyacid_8_0"]; if (dataRow.IsNull("selenium")) selenium = 0; else selenium = (Single)dataRow["selenium"]; if (dataRow.IsNull("serine")) serine = 0; else serine = (Single)dataRow["serine"]; if (dataRow.IsNull("sodium")) sodium = 0; else sodium = (Single)dataRow["sodium"]; if (dataRow.IsNull("starch")) starch = 0; else starch = (Single)dataRow["starch"]; if (dataRow.IsNull("stigmasterol")) stigmasterol = 0; else stigmasterol = (Single)dataRow["stigmasterol"]; if (dataRow.IsNull("sucrose")) sucrose = 0; else sucrose = (Single)dataRow["sucrose"]; if (dataRow.IsNull("sugar")) sugar = 0; else sugar = (Single)dataRow["sugar"]; if (dataRow.IsNull("sugaralcohols")) sugaralcohols = 0; else sugaralcohols = (Single)dataRow["sugaralcohols"]; if (dataRow.IsNull("theobromine")) theobromine = 0; else theobromine = (Single)dataRow["theobromine"]; if (dataRow.IsNull("thiamin")) thiamin = 0; else thiamin = (Single)dataRow["thiamin"]; if (dataRow.IsNull("threonine")) threonine = 0; else threonine = (Single)dataRow["threonine"]; if (dataRow.IsNull("totalcarbohydrate")) totalcarbohydrate = 0; else totalcarbohydrate = (Single)dataRow["totalcarbohydrate"]; if (dataRow.IsNull("totalfat")) totalfat = 0; else totalfat = (Single)dataRow["totalfat"]; if (dataRow.IsNull("transfattyacids")) transfattyacids = 0; else transfattyacids = (Single)dataRow["transfattyacids"]; if (dataRow.IsNull("transmonoenoicfattyacids")) transmonoenoicfattyacids = 0; else transmonoenoicfattyacids = (Single)dataRow["transmonoenoicfattyacids"]; if (dataRow.IsNull("transpolyenoicfattyacids")) transpolyenoicfattyacids = 0; else transpolyenoicfattyacids = (Single)dataRow["transpolyenoicfattyacids"]; if (dataRow.IsNull("tryptophan")) tryptophan = 0; else tryptophan = (Single)dataRow["tryptophan"]; if (dataRow.IsNull("tyrosine")) tyrosine = 0; else tyrosine = (Single)dataRow["tyrosine"]; if (dataRow.IsNull("valine")) valine = 0; else valine = (Single)dataRow["valine"]; if (dataRow.IsNull("vitamina")) vitamina = 0; else vitamina = (Single)dataRow["vitamina"]; if (dataRow.IsNull("vitaminb12")) vitaminb12 = 0; else vitaminb12 = (Single)dataRow["vitaminb12"]; if (dataRow.IsNull("vitaminb6")) vitaminb6 = 0; else vitaminb6 = (Single)dataRow["vitaminb6"]; if (dataRow.IsNull("vitaminc")) vitaminc = 0; else vitaminc = (Single)dataRow["vitaminc"]; if (dataRow.IsNull("vitamind")) vitamind = 0; else vitamind = (Single)dataRow["vitamind"]; if (dataRow.IsNull("vitamine")) vitamine = 0; else vitamine = (Single)dataRow["vitamine"]; if (dataRow.IsNull("vitamink")) vitamink = 0; else vitamink = (Single)dataRow["vitamink"]; if (dataRow.IsNull("volume")) volume = 0; else volume = (Single)dataRow["volume"]; if (dataRow.IsNull("water")) water = 0; else water = (Single)dataRow["water"]; if (dataRow.IsNull("zinc")) zinc = 0; else zinc = (Single)dataRow["zinc"]; //Populate child objects DataSet recordSet; recordSet = clsDatabaseLayer.GetDatabaseLayer().GetRecipeIngredientsByRecipeID(recipeID.Value); foreach (DataRow childDataRow in recordSet.Tables[0].Rows) { var newIngredient = RecipeIngredient.GetRecipeIngredientByDataRow(childDataRow); recipeIngredients.Add(newIngredient); } recordSet = clsDatabaseLayer.GetDatabaseLayer().GetRecipeProceduresByRecipeID(recipeID.Value); foreach (DataRow childDataRow in recordSet.Tables[0].Rows) { var newProcedure = RecipeProcedure.GetRecipeProcedureByDataRow(childDataRow); recipeProcedures.Add(newProcedure); } recordSet = clsDatabaseLayer.GetDatabaseLayer().GetRecipeTipsByRecipeID(recipeID.Value); foreach (DataRow childDataRow in recordSet.Tables[0].Rows) { var newTip = RecipeTip.GetRecipeTipByDataRow(childDataRow); recipeTips.Add(newTip); } } private void InitializeAllFields() { recipeID = null; cookbookID = null; cookbookchapterID = null; recipename = String.Empty; author = String.Empty; source = String.Empty; webpage = String.Empty; comments = String.Empty; copyright = String.Empty; servings = 0; nutritionservinglabel = String.Empty; yield = String.Empty; preparationtime = 0; cookingtime = 0; readyintime = 0; inactivetime = 0; oventemperaturec = 0; oventemperaturef = 0; percentcaloriesfromalcohol = 0; percentcaloriesfromcarbs = 0; percentcaloriesfromfat = 0; percentcaloriesfromprotein = 0; alanine = 0; alcohol = 0; alcoholfactor = 0; alphacarotene = 0; alphalinolenicacid = 0; arachidonicacid = 0; arginine = 0; ash = 0; asparticacid = 0; betacarotene = 0; betacryptoxanthin = 0; betasitosterol = 0; betatocopherol = 0; biotin = 0; caffeine = 0; calcium = 0; calories = 0; caloriesfromalcohol = 0; caloriesfromcarbs = 0; caloriesfromfat = 0; caloriesfromprotein = 0; campesterol = 0; carbohydratefactor = 0; chloride = 0; cholesterol = 0; choline = 0; chromium = 0; copper = 0; cystine = 0; deltatocopherol = 0; dihomogammalinolenicacid = 0; docosahexaenoicacid = 0; docosapentaenoicacid = 0; eicosadienoicacid = 0; eicosapentaenoicacid = 0; energy = 0; energyfromalcohol = 0; energyfromcarbs = 0; energyfromfat = 0; energyfromprotein = 0; fatfactor = 0; fiber = 0; fluoride = 0; folate = 0; fructose = 0; galactose = 0; gammalinolenicacid = 0; gammatocopherol = 0; glucose = 0; glutamicacid = 0; glycine = 0; histidine = 0; hydroxyproline = 0; iodine = 0; iron = 0; isoleucine = 0; lactose = 0; leucine = 0; linoleicacid = 0; lycopene = 0; lysine = 0; magnesium = 0; maltose = 0; manganese = 0; mass = 0; methionine = 0; molybdenum = 0; monounsaturatedfat = 0; monounsaturatedfattyacid_14_1 = 0; monounsaturatedfattyacid_15_1 = 0; monounsaturatedfattyacid_16_1 = 0; monounsaturatedfattyacid_17_1 = 0; monounsaturatedfattyacid_18_1 = 0; monounsaturatedfattyacid_20_1 = 0; monounsaturatedfattyacid_22_1 = 0; monounsaturatedfattyacid_24_1 = 0; netcarbohydrates = 0; niacin = 0; omega3fattyacids = 0; omega6fattyacids = 0; pantothenicacid = 0; phenylalanine = 0; phosphorus = 0; phytosterols = 0; polyunsaturatedfat = 0; polyunsaturatedfattyacid_18_2 = 0; polyunsaturatedfattyacid_18_3 = 0; polyunsaturatedfattyacid_18_4 = 0; polyunsaturatedfattyacid_20_3 = 0; polyunsaturatedfattyacid_20_4 = 0; polyunsaturatedfattyacid_21_5 = 0; polyunsaturatedfattyacid_22_4 = 0; potassium = 0; proline = 0; protein = 0; proteinfactor = 0; refuse = 0; retinol = 0; riboflavin = 0; saturatedfat = 0; saturatedfattyacid_10_0 = 0; saturatedfattyacid_12_0 = 0; saturatedfattyacid_13_0 = 0; saturatedfattyacid_14_0 = 0; saturatedfattyacid_15_0 = 0; saturatedfattyacid_16_0 = 0; saturatedfattyacid_17_0 = 0; saturatedfattyacid_18_0 = 0; saturatedfattyacid_20_0 = 0; saturatedfattyacid_22_0 = 0; saturatedfattyacid_24_0 = 0; saturatedfattyacid_4_0 = 0; saturatedfattyacid_6_0 = 0; saturatedfattyacid_8_0 = 0; selenium = 0; serine = 0; sodium = 0; starch = 0; stigmasterol = 0; sucrose = 0; sugar = 0; sugaralcohols = 0; theobromine = 0; thiamin = 0; threonine = 0; totalcarbohydrate = 0; totalfat = 0; transfattyacids = 0; transmonoenoicfattyacids = 0; transpolyenoicfattyacids = 0; tryptophan = 0; tyrosine = 0; valine = 0; vitamina = 0; vitaminb12 = 0; vitaminb6 = 0; vitaminc = 0; vitamind = 0; vitamine = 0; vitamink = 0; volume = 0; water = 0; zinc = 0; recipeIngredients = new List(); recipeProcedures = new List(); recipeTips = new List(); } public String GetHTML(List trackbackList) { var builder = new HtmlContentBuilder(); builder.AppendHtmlLine(""); builder.AppendHtmlLine(""); builder.AppendFormat("{0}" + Constants.CRLF, this.recipename); builder.AppendHtmlLine(""); builder.AppendHtmlLine(""); builder.AppendHtmlLine(""); builder.AppendHtmlLine(""); builder.AppendHtmlLine(""); builder.AppendHtmlLine(""); builder.AppendHtmlLine(HTMLAddTrackbackLinks(trackbackList)); builder.AppendHtml(HTMLAddRecipeName()); builder.AppendHtml(HTMLAddRecipeComments()); builder.AppendHtml(HTMLAddAllIngredients()); builder.AppendHtml(HTMLAddAllProcedures()); builder.AppendHtml(HTMLAddServingsYieldNutrition()); builder.AppendHtml(HTMLAddAllTips()); builder.AppendHtml(HTMLAddSourceInfo()); builder.AppendHtmlLine("
"); builder.AppendHtmlLine(""); builder.AppendHtmlLine(""); using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddTrackbackLinks(List trackbackList) { if ((trackbackList?.Count() ?? 0) == 0) { return String.Empty; } var builder = new HtmlContentBuilder(); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtml(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddRecipeName() { var builder = new HtmlContentBuilder(); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtml("

"); builder.AppendFormat("{0}", this.recipename); builder.AppendHtmlLine("

"); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddRecipeComments() { var builder = new HtmlContentBuilder(); if (!String.IsNullOrWhiteSpace(this.comments)) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtml("

"); builder.AppendFormat("{0}", this.comments); builder.AppendHtmlLine("

"); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); } using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddAllIngredients() { var builder = new HtmlContentBuilder(); if (this.recipeIngredients.Count > 0) { //First build the two columns of ingredients List ingredientsFirstColumn = new List(); List ingredientsSecondColumn = new List(); for (int intIngredientIndex = 0; intIngredientIndex < this.recipeIngredients.Count; intIngredientIndex++) { if (intIngredientIndex < ((double)this.recipeIngredients.Count / 2D)) { ingredientsFirstColumn.Add(this.recipeIngredients[intIngredientIndex]); } else { ingredientsSecondColumn.Add(this.recipeIngredients[intIngredientIndex]); } } if (ingredientsFirstColumn.Count > 0 && ingredientsSecondColumn.Count > 0) { //Check for only two ingredients. If so, put both on first column if (ingredientsFirstColumn.Count == 1 && ingredientsSecondColumn.Count == 1) { ingredientsFirstColumn.Add(ingredientsSecondColumn[0]); ingredientsSecondColumn.RemoveAt(0); } else { //Check for orphan header at end of first column. Move to second column if orphaned if (ingredientsFirstColumn[ingredientsFirstColumn.Count - 1].isHeading && ingredientsSecondColumn[ingredientsSecondColumn.Count - 1].isHeading == false) { ingredientsSecondColumn.Insert(0, ingredientsFirstColumn[ingredientsFirstColumn.Count - 1]); ingredientsFirstColumn.RemoveAt(ingredientsFirstColumn.Count - 1); } } } //Now build the display for the two columns StringBuilder ingredientsDisplayFirstColumn = new StringBuilder(); StringBuilder ingredientsDisplaySecondColumn = new StringBuilder(); foreach(var ingredient in ingredientsFirstColumn) { ingredientsDisplayFirstColumn.Append(HTMLAddIngredient(ingredient)); } foreach (var ingredient in ingredientsSecondColumn) { ingredientsDisplaySecondColumn.Append(HTMLAddIngredient(ingredient)); } //Now put those two columns into the HTML builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); } using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddIngredient(RecipeIngredient ingredient) { var builder = new HtmlContentBuilder(); if (ingredient.isHeading) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); } else { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); } using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddAllProcedures() { var builder = new HtmlContentBuilder(); if (this.recipeProcedures.Count > 0) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine("
"); builder.AppendHtmlLine(" "); builder.AppendHtml(ingredientsDisplayFirstColumn.ToString()); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("
"); builder.AppendHtmlLine(" "); builder.AppendHtml(ingredientsDisplaySecondColumn.ToString()); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("
"); builder.AppendHtml("

"); builder.AppendFormat("{0}", ingredient.ingredientText); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtml("

"); builder.AppendFormat("{0}", ((RecipeIngredientItem)ingredient).quantityText); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtml("

"); builder.AppendFormat("{0}", ((RecipeIngredientItem)ingredient).unitText); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtml("

"); builder.AppendFormat("{0}", ingredient.ingredientText); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtmlLine(" "); int taskNumber = 1; foreach (var recipeProcedure in this.recipeProcedures) { if (recipeProcedure.isHeading) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); //reset task number taskNumber = 1; } else { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); taskNumber += 1; } } builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); } using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddAllTips() { var builder = new HtmlContentBuilder(); if (this.recipeTips.Count > 0) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); } using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddServingsYieldNutrition() { var builder = new HtmlContentBuilder(); var needTopMargin = true; var styleToUse = String.Empty; var servingsToUse = this.servings; if (servingsToUse == 0) { servingsToUse = 1; } if (this.servings > 0) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); if (!String.IsNullOrWhiteSpace(this.yield)) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); } builder.AppendHtmlLine(" "); builder.AppendHtmlLine("
"); builder.AppendHtml("

"); builder.AppendFormat("{0}",recipeProcedure.procedureText); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtml("

"); builder.AppendFormat("{0}", taskNumber.ToString()); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtml("

"); builder.AppendFormat("{0}", recipeProcedure.procedureText); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("

Tips

"); foreach (var recipeTip in this.recipeTips) { if (recipeTip.isHeading) { builder.AppendHtml("

"); } else { builder.AppendHtml("

"); } builder.AppendFormat("{0}", recipeTip.tipText); builder.AppendHtmlLine("

"); } builder.AppendHtmlLine("
"); if (needTopMargin) { styleToUse = "style=\"MARGIN-TOP: 0.11in; MARGIN-BOTTOM: 0in;\""; needTopMargin = false; } else { styleToUse = "style=\"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in;\""; } builder.AppendHtml("

"); builder.AppendFormat("{0}", "Servings: " + this.servings.ToString()); builder.AppendHtmlLine("

"); } builder.AppendHtmlLine("
"); if (needTopMargin) { styleToUse = "style=\"MARGIN-TOP: 0.11in; MARGIN-BOTTOM: 0in;\""; needTopMargin = false; } else { styleToUse = "style=\"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in;\""; } builder.AppendHtml("

"); builder.AppendFormat("{0}", "Yield: " + this.yield); builder.AppendHtmlLine("

"); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("

Nutrition Facts

"); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } private String HTMLAddSourceInfo() { var builder = new HtmlContentBuilder(); var needTopMargin = true; var styleToUse = String.Empty; if (!String.IsNullOrWhiteSpace(this.source) || !String.IsNullOrWhiteSpace(this.webpage) || !String.IsNullOrWhiteSpace(this.copyright)) { builder.AppendHtmlLine(" "); builder.AppendHtmlLine("
"); if (servingsToUse == 1) { builder.AppendFormat("

Serving size: Entire recipe. ({0} g)", this.mass.ToString("F2")); } else { builder.AppendFormat("

Serving size: 1/{0} of a recipe. ({1} g)", servingsToUse.ToString(), this.mass.ToString("F2")); } builder.AppendHtmlLine("

"); builder.AppendHtmlLine("

Percent daily values based on the Reference Daily Intake (RDI) for a 2000 calorie diet.

"); builder.AppendHtmlLine("

Nutrition information calculated from recipe ingredients.

"); int totalIngredients = 0; int totalIngredientsLinked = 0; int totalIngredientsNotLinked = 0; foreach (var recipeIngredient in this.recipeIngredients) { if (recipeIngredient is RecipeIngredientItem) { totalIngredients += 1; var recipeIngredientItem = (RecipeIngredientItem)recipeIngredient; if (recipeIngredientItem.ingredientID != null) { totalIngredientsLinked += 1; } else { totalIngredientsNotLinked += 1; } } } if (totalIngredients > 0 && totalIngredientsNotLinked > 0) { if (totalIngredientsNotLinked == 1) { builder.AppendHtmlLine("

There is an ingredient not linked for nutrition

"); } else { builder.AppendFormat("

There are {0} ingredient(s) not linked for nutrition

" + Constants.CRLF, totalIngredientsNotLinked.ToString()); } } builder.AppendHtmlLine("
"); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine(" "); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("

Amount Per Serving

"); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("

Calories

"); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}

" + Constants.CRLF, this.calories.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Calories From Fat ({0}%)

" + Constants.CRLF, this.percentcaloriesfromfat.ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}

" + Constants.CRLF, this.caloriesfromfat.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("

% Daily Value

"); builder.AppendHtmlLine("
"); builder.AppendFormat("

Total Fat {0}g

" + Constants.CRLF,this.totalfat.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.totalfat * 100)/Constants.DAILY_VALUE_FAT).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Saturated Fat {0}g

" + Constants.CRLF,this.saturatedfat.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.saturatedfat * 100)/Constants.DAILY_VALUE_SATURATED_FAT).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Cholesterol {0}mg

" + Constants.CRLF,this.cholesterol.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.cholesterol * 100)/Constants.DAILY_VALUE_CHOLESTEROL).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Sodium {0}mg

" + Constants.CRLF,this.sodium.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.sodium * 100)/Constants.DAILY_VALUE_SODIUM).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Potassium {0}mg

" + Constants.CRLF,this.potassium.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.potassium * 100)/Constants.DAILY_VALUE_POTASSIUM).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Total Carbohydrates {0}g

" + Constants.CRLF,this.totalcarbohydrate.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.totalcarbohydrate * 100)/Constants.DAILY_VALUE_TOTAL_CARBOHYDRATE).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Fiber {0}g

" + Constants.CRLF,this.fiber.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.fiber * 100)/Constants.DAILY_VALUE_DIETARY_FIBER).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendFormat("

Sugar {0}g

" + Constants.CRLF,this.sugar.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("

 

"); builder.AppendHtmlLine("
"); builder.AppendFormat("

Protein {0}g

" + Constants.CRLF,this.protein.ToString("F2")); builder.AppendHtmlLine("
"); builder.AppendFormat("

{0}%

" + Constants.CRLF,((this.protein * 100)/Constants.DAILY_VALUE_PROTEIN).ToString("F0")); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("
"); builder.AppendHtmlLine("

Source

"); if (!String.IsNullOrWhiteSpace(this.source)) { if (needTopMargin) { styleToUse = "style=\"MARGIN-TOP: 0.11in; MARGIN-BOTTOM: 0in;\""; needTopMargin = false; } else { styleToUse = "style=\"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in;\""; } builder.AppendFormat("

{0}

" + Constants.CRLF,"Source: " + this.source); } if (!String.IsNullOrWhiteSpace(this.webpage)) { if (needTopMargin) { styleToUse = "style=\"MARGIN-TOP: 0.11in; MARGIN-BOTTOM: 0in;\""; needTopMargin = false; } else { styleToUse = "style=\"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in;\""; } builder.AppendFormat("

{0}

" + Constants.CRLF, "Web Page: " + this.webpage); } if (!String.IsNullOrWhiteSpace(this.copyright)) { if (needTopMargin) { styleToUse = "style=\"MARGIN-TOP: 0.11in; MARGIN-BOTTOM: 0in;\""; needTopMargin = false; } else { styleToUse = "style=\"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in;\""; } builder.AppendFormat("

{0}

" + Constants.CRLF, "Copyright: " + this.copyright); } } using (var writer = new System.IO.StringWriter()) { builder.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); return writer.ToString(); } } public void CalcNutrition() { alanine = 0; alcohol = 0; alcoholfactor = 0; alphacarotene = 0; alphalinolenicacid = 0; arachidonicacid = 0; arginine = 0; ash = 0; asparticacid = 0; betacarotene = 0; betacryptoxanthin = 0; betasitosterol = 0; betatocopherol = 0; biotin = 0; caffeine = 0; calcium = 0; calories = 0; caloriesfromalcohol = 0; caloriesfromcarbs = 0; caloriesfromfat = 0; caloriesfromprotein = 0; campesterol = 0; carbohydratefactor = 0; chloride = 0; cholesterol = 0; choline = 0; chromium = 0; copper = 0; cystine = 0; deltatocopherol = 0; dihomogammalinolenicacid = 0; docosahexaenoicacid = 0; docosapentaenoicacid = 0; eicosadienoicacid = 0; eicosapentaenoicacid = 0; energy = 0; energyfromalcohol = 0; energyfromcarbs = 0; energyfromfat = 0; energyfromprotein = 0; fatfactor = 0; fiber = 0; fluoride = 0; folate = 0; fructose = 0; galactose = 0; gammalinolenicacid = 0; gammatocopherol = 0; glucose = 0; glutamicacid = 0; glycine = 0; histidine = 0; hydroxyproline = 0; iodine = 0; iron = 0; isoleucine = 0; lactose = 0; leucine = 0; linoleicacid = 0; lycopene = 0; lysine = 0; magnesium = 0; maltose = 0; manganese = 0; mass = 0; methionine = 0; molybdenum = 0; monounsaturatedfat = 0; monounsaturatedfattyacid_14_1 = 0; monounsaturatedfattyacid_15_1 = 0; monounsaturatedfattyacid_16_1 = 0; monounsaturatedfattyacid_17_1 = 0; monounsaturatedfattyacid_18_1 = 0; monounsaturatedfattyacid_20_1 = 0; monounsaturatedfattyacid_22_1 = 0; monounsaturatedfattyacid_24_1 = 0; netcarbohydrates = 0; niacin = 0; omega3fattyacids = 0; omega6fattyacids = 0; pantothenicacid = 0; phenylalanine = 0; phosphorus = 0; phytosterols = 0; polyunsaturatedfat = 0; polyunsaturatedfattyacid_18_2 = 0; polyunsaturatedfattyacid_18_3 = 0; polyunsaturatedfattyacid_18_4 = 0; polyunsaturatedfattyacid_20_3 = 0; polyunsaturatedfattyacid_20_4 = 0; polyunsaturatedfattyacid_21_5 = 0; polyunsaturatedfattyacid_22_4 = 0; potassium = 0; proline = 0; protein = 0; proteinfactor = 0; refuse = 0; retinol = 0; riboflavin = 0; saturatedfat = 0; saturatedfattyacid_10_0 = 0; saturatedfattyacid_12_0 = 0; saturatedfattyacid_13_0 = 0; saturatedfattyacid_14_0 = 0; saturatedfattyacid_15_0 = 0; saturatedfattyacid_16_0 = 0; saturatedfattyacid_17_0 = 0; saturatedfattyacid_18_0 = 0; saturatedfattyacid_20_0 = 0; saturatedfattyacid_22_0 = 0; saturatedfattyacid_24_0 = 0; saturatedfattyacid_4_0 = 0; saturatedfattyacid_6_0 = 0; saturatedfattyacid_8_0 = 0; selenium = 0; serine = 0; sodium = 0; starch = 0; stigmasterol = 0; sucrose = 0; sugar = 0; sugaralcohols = 0; theobromine = 0; thiamin = 0; threonine = 0; totalcarbohydrate = 0; totalfat = 0; transfattyacids = 0; transmonoenoicfattyacids = 0; transpolyenoicfattyacids = 0; tryptophan = 0; tyrosine = 0; valine = 0; vitamina = 0; vitaminb12 = 0; vitaminb6 = 0; vitaminc = 0; vitamind = 0; vitamine = 0; vitamink = 0; volume = 0; water = 0; zinc = 0; Single servingsToUse = this.servings; if (servingsToUse == 0) { servingsToUse = 1; } foreach (var recipeIngredient in this.recipeIngredients) { if (recipeIngredient is RecipeIngredientItem) { var recipeIngredientItem = (RecipeIngredientItem)recipeIngredient; if (recipeIngredientItem.ingredientID != null && recipeIngredientItem.measureID != null) { var ingredient = new Ingredient(recipeIngredientItem.ingredientID.Value); var gramWeight = ingredient.GramWeightByMeasureID(recipeIngredientItem.measureID.Value); this.alanine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.alanine); this.alcohol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.alcohol); this.alphacarotene += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.alphacarotene); this.alphalinolenicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.alphalinolenicacid); this.arachidonicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.arachidonicacid); this.arginine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.arginine); this.ash += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.ash); this.asparticacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.asparticacid); this.betacarotene += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.betacarotene); this.betacryptoxanthin += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.betacryptoxanthin); this.betasitosterol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.betasitosterol); this.betatocopherol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.betatocopherol); this.biotin += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.biotin); this.caffeine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.caffeine); this.calcium += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.calcium); this.calories += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.calories); this.caloriesfromalcohol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.caloriesfromalcohol); this.caloriesfromcarbs += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.caloriesfromcarbs); this.caloriesfromfat += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.caloriesfromfat); this.caloriesfromprotein += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.caloriesfromprotein); this.campesterol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.campesterol); this.chloride += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.chloride); this.cholesterol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.cholesterol); this.choline += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.choline); this.chromium += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.chromium); this.copper += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.copper); this.cystine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.cystine); this.deltatocopherol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.deltatocopherol); this.dihomogammalinolenicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.dihomogammalinolenicacid); this.docosahexaenoicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.docosahexaenoicacid); this.docosapentaenoicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.docosapentaenoicacid); this.eicosadienoicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.eicosadienoicacid); this.eicosapentaenoicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.eicosapentaenoicacid); this.energy += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.energy); this.energyfromalcohol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.energyfromalcohol); this.energyfromcarbs += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.energyfromcarbs); this.energyfromfat += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.energyfromfat); this.energyfromprotein += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.energyfromprotein); this.fiber += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.fiber); this.fluoride += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.fluoride); this.folate += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.folate); this.fructose += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.fructose); this.galactose += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.galactose); this.gammalinolenicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.gammalinolenicacid); this.gammatocopherol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.gammatocopherol); this.glucose += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.glucose); this.glutamicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.glutamicacid); this.glycine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.glycine); this.histidine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.histidine); this.hydroxyproline += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.hydroxyproline); this.iodine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.iodine); this.iron += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.iron); this.isoleucine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.isoleucine); this.lactose += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.lactose); this.leucine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.leucine); this.linoleicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.linoleicacid); this.lycopene += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.lycopene); this.lysine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.lysine); this.magnesium += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.magnesium); this.maltose += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.maltose); this.manganese += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.manganese); //mass calculated differently, since it directly uses gramWeight of ingredient this.mass += recipeIngredientItem.measureQuantity * gramWeight; this.methionine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.methionine); this.molybdenum += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.molybdenum); this.monounsaturatedfat += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfat); this.monounsaturatedfattyacid_14_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_14_1); this.monounsaturatedfattyacid_15_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_15_1); this.monounsaturatedfattyacid_16_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_16_1); this.monounsaturatedfattyacid_17_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_17_1); this.monounsaturatedfattyacid_18_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_18_1); this.monounsaturatedfattyacid_20_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_20_1); this.monounsaturatedfattyacid_22_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_22_1); this.monounsaturatedfattyacid_24_1 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.monounsaturatedfattyacid_24_1); this.netcarbohydrates += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.netcarbohydrates); this.niacin += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.niacin); this.omega3fattyacids += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.omega3fattyacids); this.omega6fattyacids += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.omega6fattyacids); this.pantothenicacid += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.pantothenicacid); this.phenylalanine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.phenylalanine); this.phosphorus += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.phosphorus); this.phytosterols += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.phytosterols); this.polyunsaturatedfat += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfat); this.polyunsaturatedfattyacid_18_2 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfattyacid_18_2); this.polyunsaturatedfattyacid_18_3 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfattyacid_18_3); this.polyunsaturatedfattyacid_18_4 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfattyacid_18_4); this.polyunsaturatedfattyacid_20_3 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfattyacid_20_3); this.polyunsaturatedfattyacid_20_4 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfattyacid_20_4); this.polyunsaturatedfattyacid_21_5 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfattyacid_21_5); this.polyunsaturatedfattyacid_22_4 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.polyunsaturatedfattyacid_22_4); this.potassium += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.potassium); this.proline += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.proline); this.protein += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.protein); this.refuse += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.refuse); this.retinol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.retinol); this.riboflavin += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.riboflavin); this.saturatedfat += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfat); this.saturatedfattyacid_10_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_10_0); this.saturatedfattyacid_12_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_12_0); this.saturatedfattyacid_13_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_13_0); this.saturatedfattyacid_14_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_14_0); this.saturatedfattyacid_15_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_15_0); this.saturatedfattyacid_16_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_16_0); this.saturatedfattyacid_17_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_17_0); this.saturatedfattyacid_18_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_18_0); this.saturatedfattyacid_20_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_20_0); this.saturatedfattyacid_22_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_22_0); this.saturatedfattyacid_24_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_24_0); this.saturatedfattyacid_4_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_4_0); this.saturatedfattyacid_6_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_6_0); this.saturatedfattyacid_8_0 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.saturatedfattyacid_8_0); this.selenium += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.selenium); this.serine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.serine); this.sodium += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.sodium); this.starch += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.starch); this.stigmasterol += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.stigmasterol); this.sucrose += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.sucrose); this.sugar += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.sugar); this.sugaralcohols += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.sugaralcohols); this.theobromine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.theobromine); this.thiamin += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.thiamin); this.threonine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.threonine); this.totalcarbohydrate += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.totalcarbohydrate); this.totalfat += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.totalfat); this.transfattyacids += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.transfattyacids); this.transmonoenoicfattyacids += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.transmonoenoicfattyacids); this.transpolyenoicfattyacids += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.transpolyenoicfattyacids); this.tryptophan += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.tryptophan); this.tyrosine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.tyrosine); this.valine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.valine); this.vitamina += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.vitamina); this.vitaminb12 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.vitaminb12); this.vitaminb6 += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.vitaminb6); this.vitaminc += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.vitaminc); this.vitamind += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.vitamind); this.vitamine += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.vitamine); this.vitamink += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.vitamink); this.volume += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.volume); this.water += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.water); this.zinc += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.zinc); this.alcoholfactor += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.alcoholfactor); this.carbohydratefactor += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.carbohydratefactor); this.fatfactor += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.fatfactor); this.proteinfactor += GetNutrientItemAmount(recipeIngredientItem, gramWeight, ingredient.proteinfactor); } } } if (this.calories == 0) { this.percentcaloriesfromalcohol = 0; this.percentcaloriesfromcarbs = 0; this.percentcaloriesfromfat = 0; this.percentcaloriesfromprotein = 0; } else { this.percentcaloriesfromalcohol = (100F * this.caloriesfromalcohol) / this.calories; this.percentcaloriesfromcarbs = (100F * this.caloriesfromcarbs) / this.calories; this.percentcaloriesfromfat = (100F * this.caloriesfromfat) / this.calories; this.percentcaloriesfromprotein = (100F * this.caloriesfromprotein) / this.calories; } this.netcarbohydrates = this.totalcarbohydrate - this.fiber - this.sugaralcohols; this.alanine = this.alanine / servingsToUse; this.alcohol = this.alcohol / servingsToUse; this.alcoholfactor = this.alcoholfactor / servingsToUse; this.alphacarotene = this.alphacarotene / servingsToUse; this.alphalinolenicacid = this.alphalinolenicacid / servingsToUse; this.arachidonicacid = this.arachidonicacid / servingsToUse; this.arginine = this.arginine / servingsToUse; this.ash = this.ash / servingsToUse; this.asparticacid = this.asparticacid / servingsToUse; this.betacarotene = this.betacarotene / servingsToUse; this.betacryptoxanthin = this.betacryptoxanthin / servingsToUse; this.betasitosterol = this.betasitosterol / servingsToUse; this.betatocopherol = this.betatocopherol / servingsToUse; this.biotin = this.biotin / servingsToUse; this.caffeine = this.caffeine / servingsToUse; this.calcium = this.calcium / servingsToUse; this.calories = this.calories / servingsToUse; this.caloriesfromalcohol = this.caloriesfromalcohol / servingsToUse; this.caloriesfromcarbs = this.caloriesfromcarbs / servingsToUse; this.caloriesfromfat = this.caloriesfromfat / servingsToUse; this.caloriesfromprotein = this.caloriesfromprotein / servingsToUse; this.campesterol = this.campesterol / servingsToUse; this.carbohydratefactor = this.carbohydratefactor / servingsToUse; this.chloride = this.chloride / servingsToUse; this.cholesterol = this.cholesterol / servingsToUse; this.choline = this.choline / servingsToUse; this.chromium = this.chromium / servingsToUse; this.copper = this.copper / servingsToUse; this.cystine = this.cystine / servingsToUse; this.deltatocopherol = this.deltatocopherol / servingsToUse; this.dihomogammalinolenicacid = this.dihomogammalinolenicacid / servingsToUse; this.docosahexaenoicacid = this.docosahexaenoicacid / servingsToUse; this.docosapentaenoicacid = this.docosapentaenoicacid / servingsToUse; this.eicosadienoicacid = this.eicosadienoicacid / servingsToUse; this.eicosapentaenoicacid = this.eicosapentaenoicacid / servingsToUse; this.energy = this.energy / servingsToUse; this.energyfromalcohol = this.energyfromalcohol / servingsToUse; this.energyfromcarbs = this.energyfromcarbs / servingsToUse; this.energyfromfat = this.energyfromfat / servingsToUse; this.energyfromprotein = this.energyfromprotein / servingsToUse; this.fatfactor = this.fatfactor / servingsToUse; this.fiber = this.fiber / servingsToUse; this.fluoride = this.fluoride / servingsToUse; this.folate = this.folate / servingsToUse; this.fructose = this.fructose / servingsToUse; this.galactose = this.galactose / servingsToUse; this.gammalinolenicacid = this.gammalinolenicacid / servingsToUse; this.gammatocopherol = this.gammatocopherol / servingsToUse; this.glucose = this.glucose / servingsToUse; this.glutamicacid = this.glutamicacid / servingsToUse; this.glycine = this.glycine / servingsToUse; this.histidine = this.histidine / servingsToUse; this.hydroxyproline = this.hydroxyproline / servingsToUse; this.iodine = this.iodine / servingsToUse; this.iron = this.iron / servingsToUse; this.isoleucine = this.isoleucine / servingsToUse; this.lactose = this.lactose / servingsToUse; this.leucine = this.leucine / servingsToUse; this.linoleicacid = this.linoleicacid / servingsToUse; this.lycopene = this.lycopene / servingsToUse; this.lysine = this.lysine / servingsToUse; this.magnesium = this.magnesium / servingsToUse; this.maltose = this.maltose / servingsToUse; this.manganese = this.manganese / servingsToUse; this.mass = this.mass / servingsToUse; this.methionine = this.methionine / servingsToUse; this.molybdenum = this.molybdenum / servingsToUse; this.monounsaturatedfat = this.monounsaturatedfat / servingsToUse; this.monounsaturatedfattyacid_14_1 = this.monounsaturatedfattyacid_14_1 / servingsToUse; this.monounsaturatedfattyacid_15_1 = this.monounsaturatedfattyacid_15_1 / servingsToUse; this.monounsaturatedfattyacid_16_1 = this.monounsaturatedfattyacid_16_1 / servingsToUse; this.monounsaturatedfattyacid_17_1 = this.monounsaturatedfattyacid_17_1 / servingsToUse; this.monounsaturatedfattyacid_18_1 = this.monounsaturatedfattyacid_18_1 / servingsToUse; this.monounsaturatedfattyacid_20_1 = this.monounsaturatedfattyacid_20_1 / servingsToUse; this.monounsaturatedfattyacid_22_1 = this.monounsaturatedfattyacid_22_1 / servingsToUse; this.monounsaturatedfattyacid_24_1 = this.monounsaturatedfattyacid_24_1 / servingsToUse; this.netcarbohydrates = this.netcarbohydrates / servingsToUse; this.niacin = this.niacin / servingsToUse; this.omega3fattyacids = this.omega3fattyacids / servingsToUse; this.omega6fattyacids = this.omega6fattyacids / servingsToUse; this.pantothenicacid = this.pantothenicacid / servingsToUse; this.phenylalanine = this.phenylalanine / servingsToUse; this.phosphorus = this.phosphorus / servingsToUse; this.phytosterols = this.phytosterols / servingsToUse; this.polyunsaturatedfat = this.polyunsaturatedfat / servingsToUse; this.polyunsaturatedfattyacid_18_2 = this.polyunsaturatedfattyacid_18_2 / servingsToUse; this.polyunsaturatedfattyacid_18_3 = this.polyunsaturatedfattyacid_18_3 / servingsToUse; this.polyunsaturatedfattyacid_18_4 = this.polyunsaturatedfattyacid_18_4 / servingsToUse; this.polyunsaturatedfattyacid_20_3 = this.polyunsaturatedfattyacid_20_3 / servingsToUse; this.polyunsaturatedfattyacid_20_4 = this.polyunsaturatedfattyacid_20_4 / servingsToUse; this.polyunsaturatedfattyacid_21_5 = this.polyunsaturatedfattyacid_21_5 / servingsToUse; this.polyunsaturatedfattyacid_22_4 = this.polyunsaturatedfattyacid_22_4 / servingsToUse; this.potassium = this.potassium / servingsToUse; this.proline = this.proline / servingsToUse; this.protein = this.protein / servingsToUse; this.proteinfactor = this.proteinfactor / servingsToUse; this.refuse = this.refuse / servingsToUse; this.retinol = this.retinol / servingsToUse; this.riboflavin = this.riboflavin / servingsToUse; this.saturatedfat = this.saturatedfat / servingsToUse; this.saturatedfattyacid_10_0 = this.saturatedfattyacid_10_0 / servingsToUse; this.saturatedfattyacid_12_0 = this.saturatedfattyacid_12_0 / servingsToUse; this.saturatedfattyacid_13_0 = this.saturatedfattyacid_13_0 / servingsToUse; this.saturatedfattyacid_14_0 = this.saturatedfattyacid_14_0 / servingsToUse; this.saturatedfattyacid_15_0 = this.saturatedfattyacid_15_0 / servingsToUse; this.saturatedfattyacid_16_0 = this.saturatedfattyacid_16_0 / servingsToUse; this.saturatedfattyacid_17_0 = this.saturatedfattyacid_17_0 / servingsToUse; this.saturatedfattyacid_18_0 = this.saturatedfattyacid_18_0 / servingsToUse; this.saturatedfattyacid_20_0 = this.saturatedfattyacid_20_0 / servingsToUse; this.saturatedfattyacid_22_0 = this.saturatedfattyacid_22_0 / servingsToUse; this.saturatedfattyacid_24_0 = this.saturatedfattyacid_24_0 / servingsToUse; this.saturatedfattyacid_4_0 = this.saturatedfattyacid_4_0 / servingsToUse; this.saturatedfattyacid_6_0 = this.saturatedfattyacid_6_0 / servingsToUse; this.saturatedfattyacid_8_0 = this.saturatedfattyacid_8_0 / servingsToUse; this.selenium = this.selenium / servingsToUse; this.serine = this.serine / servingsToUse; this.sodium = this.sodium / servingsToUse; this.starch = this.starch / servingsToUse; this.stigmasterol = this.stigmasterol / servingsToUse; this.sucrose = this.sucrose / servingsToUse; this.sugar = this.sugar / servingsToUse; this.sugaralcohols = this.sugaralcohols / servingsToUse; this.theobromine = this.theobromine / servingsToUse; this.thiamin = this.thiamin / servingsToUse; this.threonine = this.threonine / servingsToUse; this.totalcarbohydrate = this.totalcarbohydrate / servingsToUse; this.totalfat = this.totalfat / servingsToUse; this.transfattyacids = this.transfattyacids / servingsToUse; this.transmonoenoicfattyacids = this.transmonoenoicfattyacids / servingsToUse; this.transpolyenoicfattyacids = this.transpolyenoicfattyacids / servingsToUse; this.tryptophan = this.tryptophan / servingsToUse; this.tyrosine = this.tyrosine / servingsToUse; this.valine = this.valine / servingsToUse; this.vitamina = this.vitamina / servingsToUse; this.vitaminb12 = this.vitaminb12 / servingsToUse; this.vitaminb6 = this.vitaminb6 / servingsToUse; this.vitaminc = this.vitaminc / servingsToUse; this.vitamind = this.vitamind / servingsToUse; this.vitamine = this.vitamine / servingsToUse; this.vitamink = this.vitamink / servingsToUse; this.volume = this.volume / servingsToUse; this.water = this.water / servingsToUse; this.zinc = this.zinc / servingsToUse; } public Single GetNutrientItemAmount(RecipeIngredientItem recipeIngredientItem, Single gramWeight, Single nutrientAmount) { return recipeIngredientItem.measureQuantity * nutrientAmount * (gramWeight / 100.0F); } public void AddToWordDoc(Microsoft.Office.Interop.Word.Application objWord, Dictionary recipePageDictionary, SortedList recipesAlpha, SortedSet pagesAlreadyAdded) { String pageNameToUse = SharedRoutines.RemoveSpecialCharactersFromFileName(this.recipename); String pageNameToUseWithExtension = pageNameToUse; while (pagesAlreadyAdded.Contains(pageNameToUseWithExtension.ToUpper())) { pageNameToUse += "1"; pageNameToUseWithExtension = pageNameToUse; } recipePageDictionary.Add(this.recipeID.Value, pageNameToUseWithExtension); recipesAlpha.Add(this.recipename.ToUpper(), this); pagesAlreadyAdded.Add(pageNameToUseWithExtension.ToUpper()); objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 1, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Cells[1].LeftPadding = 0; objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt; //objWord.Selection.Font.Bold = 1; //objWord.Selection.Font.Size = clsWord.WORD_RECIPE_NAME_FONT_SIZE; //objWord.Selection.TypeText(this.recipename); //objWord.Selection.Font.Bold = 0; objWord.Selection.set_Style(objWord.ActiveDocument.Styles["Heading 2"]); objWord.Selection.TypeText(this.recipename); //objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); objWord.Selection.set_Style(objWord.ActiveDocument.Styles["Normal"]); objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle; objWord.Selection.ParagraphFormat.SpaceAfter = 0F; objWord.ActiveDocument.Indexes.MarkEntry(objWord.Selection.Range, this.recipename, this.recipename, String.Empty, String.Empty, String.Empty, 0, 0); clsWord.AddHalfSpaceLineAtEndOfDocument(); WordDocAddComments(objWord); WordDocAddAllIngredients(objWord); WordDocAddAllProcedures(objWord); WordDocAddServingsYieldNutrition(objWord); WordDocAddAllTips(objWord); WordDocAddSourceInfo(objWord); if (RecipeRenderedEvent != null) { RecipeRenderedEvent.Invoke(this, new EventArgs()); } } public void WordDocAddComments(Microsoft.Office.Interop.Word.Application objWord) { if (!String.IsNullOrWhiteSpace(this.comments)) { objWord.Selection.TypeText(this.comments); objWord.Selection.TypeParagraph(); clsWord.AddHalfSpaceLineAtEndOfDocument(); } } private void WordDocAddAllIngredients(Microsoft.Office.Interop.Word.Application objWord) { if (this.recipeIngredients.Count > 0) { //First build the two columns List ingredientsFirstColumn = new List(); List ingredientsSecondColumn = new List(); for (int intIngredientIndex = 0; intIngredientIndex < this.recipeIngredients.Count; intIngredientIndex++) { if (intIngredientIndex < ((double)this.recipeIngredients.Count / 2D)) { ingredientsFirstColumn.Add(this.recipeIngredients[intIngredientIndex]); } else { ingredientsSecondColumn.Add(this.recipeIngredients[intIngredientIndex]); } } if (ingredientsFirstColumn.Count > 0 && ingredientsSecondColumn.Count > 0) { //Check for only two ingredients. If so, put both on first column if (ingredientsFirstColumn.Count == 1 && ingredientsSecondColumn.Count == 1) { ingredientsFirstColumn.Add(ingredientsSecondColumn[0]); ingredientsSecondColumn.RemoveAt(0); } else { //Check for orphan header at end of first column. Move to second column if orphaned if (ingredientsFirstColumn[ingredientsFirstColumn.Count - 1].isHeading && ingredientsSecondColumn[ingredientsSecondColumn.Count - 1].isHeading == false) { ingredientsSecondColumn.Insert(0, ingredientsFirstColumn[ingredientsFirstColumn.Count - 1]); ingredientsFirstColumn.RemoveAt(ingredientsFirstColumn.Count - 1); } } } objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 7, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Tables[1].Rows.AllowBreakAcrossPages = 0; objWord.Selection.Cells[1].LeftPadding = 0; objWord.Selection.Tables[1].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Tables[1].Borders.InsideLineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); //Now put those two columns into the table for (int intIngredientIndex = 0; intIngredientIndex < ingredientsFirstColumn.Count || intIngredientIndex < ingredientsSecondColumn.Count; intIngredientIndex++) { if (intIngredientIndex > 0) { objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); } if (intIngredientIndex <= ingredientsFirstColumn.Count - 1) { WordDocAddIngredient(objWord, ingredientsFirstColumn[intIngredientIndex]); } else { //make up for empty ingredient objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); } objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); if (intIngredientIndex <= ingredientsSecondColumn.Count - 1) { WordDocAddIngredient(objWord, ingredientsSecondColumn[intIngredientIndex]); } } objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); clsWord.AddHalfSpaceLineAtEndOfDocument(); } } private void WordDocAddIngredient(Microsoft.Office.Interop.Word.Application objWord, RecipeIngredient ingredient) { if (ingredient.isHeading) { objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText(ingredient.ingredientText); } else { objWord.Selection.TypeText(((RecipeIngredientItem)ingredient).quantityText); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(((RecipeIngredientItem)ingredient).unitText); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(ingredient.ingredientText); } } private void WordDocAddAllProcedures(Microsoft.Office.Interop.Word.Application objWord) { if (this.recipeProcedures.Count > 0) { int taskNumber = 1; bool blnInTable = false; foreach (var recipeProcedure in this.recipeProcedures) { if (recipeProcedure.isHeading) { if (blnInTable) { objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); blnInTable = false; } objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText(recipeProcedure.procedureText); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeParagraph(); //reset task number taskNumber = 1; } else { if (blnInTable) { objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); } else { blnInTable = true; objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 2, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Tables[1].Rows.AllowBreakAcrossPages = 0; objWord.Selection.Tables[1].BottomPadding = objWord.InchesToPoints(0.07F); objWord.Selection.Cells[1].Column.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Cells[1].Column.PreferredWidth = 4F; objWord.Selection.Cells[1].LeftPadding = 0; objWord.Selection.Tables[1].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Tables[1].Borders.InsideLineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Cells[1].Column.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Cells[1].Column.PreferredWidth = 96F; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); } objWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight; objWord.Selection.TypeText(taskNumber.ToString()); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; objWord.Selection.TypeText(recipeProcedure.procedureText); taskNumber += 1; } } if (blnInTable) { objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); blnInTable = false; } clsWord.AddHalfSpaceLineAtEndOfDocument(); } } private void WordDocAddServingsYieldNutrition(Microsoft.Office.Interop.Word.Application objWord) { var servingsToUse = this.servings; if (servingsToUse == 0) { servingsToUse = 1; } bool blnNeedSpaceBeforeNutrition = false; if (this.servings > 0) { objWord.Selection.TypeText("Servings: " + this.servings.ToString()); objWord.Selection.TypeParagraph(); blnNeedSpaceBeforeNutrition = true; } if (!String.IsNullOrWhiteSpace(this.yield)) { objWord.Selection.TypeText("Yield: " + this.yield); objWord.Selection.TypeParagraph(); blnNeedSpaceBeforeNutrition = true; } if (blnNeedSpaceBeforeNutrition) { clsWord.AddHalfSpaceLineAtEndOfDocument(); } objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 1, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Cells[1].LeftPadding = 0; objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Tables[1].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Tables[1].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Tables[1].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt; objWord.Selection.Font.Bold = 1; objWord.Selection.Font.Size = clsWord.WORD_RECIPE_SECTION_HEADING_FONT_SIZE; objWord.Selection.TypeText("Nutrition Facts"); objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); clsWord.AddHalfSpaceLineAtEndOfDocument(); objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 2, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Tables[1].Rows.AllowBreakAcrossPages = 0; objWord.Selection.Tables[1].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Tables[1].Borders.InsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Cells[1].Column.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Cells[1].Column.PreferredWidth = 67F; objWord.Selection.Cells[1].LeftPadding = 0; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Cells[1].Column.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Cells[1].Column.PreferredWidth = 33F; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone; //objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); if (servingsToUse == 1) { objWord.Selection.TypeText(String.Format("Serving size: Entire recipe. ({0}g)", this.mass.ToString("F2"))); } else { objWord.Selection.TypeText(String.Format("Serving size: 1/{0} of a recipe. ({1}g)", servingsToUse.ToString(), this.mass.ToString("F2"))); } objWord.Selection.TypeParagraph(); objWord.Selection.TypeText("Percent daily values based on the Reference Daily Intake (RDI) for a 2000 calorie diet."); objWord.Selection.TypeParagraph(); objWord.Selection.TypeText("Nutrition information calculated from recipe ingredients."); int totalIngredients = 0; int totalIngredientsLinked = 0; int totalIngredientsNotLinked = 0; foreach (var recipeIngredient in this.recipeIngredients) { if (recipeIngredient is RecipeIngredientItem) { totalIngredients += 1; var recipeIngredientItem = (RecipeIngredientItem)recipeIngredient; if (recipeIngredientItem.ingredientID != null) { totalIngredientsLinked += 1; } else { totalIngredientsNotLinked += 1; } } } if (totalIngredients > 0 && totalIngredientsNotLinked > 0) { objWord.Selection.TypeParagraph(); if (totalIngredientsNotLinked == 1) { objWord.Selection.TypeText("There is an ingredient not linked for nutrition"); } else { objWord.Selection.TypeText(String.Format("There are {0} ingredient(s) not linked for nutrition", totalIngredientsNotLinked.ToString())); } } objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 2, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Tables[1].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Tables[1].Borders.InsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Tables[1].AllowPageBreaks = false; objWord.Selection.Cells[1].Column.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Cells[1].Column.PreferredWidth = 60F; objWord.Selection.Cells[1].LeftPadding = 0; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineWidth = WdLineWidth.wdLineWidth300pt; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt; objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Cells[1].Column.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Cells[1].Column.PreferredWidth = 40F; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineWidth = WdLineWidth.wdLineWidth300pt; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt; objWord.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Size = clsWord.WORD_NUTRITION_FONT_SIZE; objWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; objWord.Selection.TypeText("Amount Per Serving"); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight; objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Size = clsWord.WORD_NUTRITION_FONT_SIZE; objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText("Calories"); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Size = clsWord.WORD_NUTRITION_FONT_SIZE; objWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight; objWord.Selection.TypeText(this.calories.ToString("F2")); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" Calories From Fat ({0}%)", this.percentcaloriesfromfat.ToString("F0"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}", this.caloriesfromfat.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineWidth = WdLineWidth.wdLineWidth150pt; objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineWidth = WdLineWidth.wdLineWidth150pt; objWord.Selection.TypeText("% Daily Value"); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineWidth = WdLineWidth.wdLineWidth050pt; objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText("Total Fat"); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" {0}g", this.totalfat.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.totalfat * 100) / Constants.DAILY_VALUE_FAT).ToString("F0"))); objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineWidth = WdLineWidth.wdLineWidth050pt; objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" Saturated Fat {0}g", this.saturatedfat.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.saturatedfat * 100) / Constants.DAILY_VALUE_SATURATED_FAT).ToString("F0"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText("Cholesterol"); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" {0}mg", this.cholesterol.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.cholesterol * 100) / Constants.DAILY_VALUE_CHOLESTEROL).ToString("F0"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText("Sodium"); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" {0}mg" , this.sodium.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.sodium * 100) / Constants.DAILY_VALUE_SODIUM).ToString("F0"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText("Potassium"); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" {0}mg", this.potassium.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.potassium * 100) / Constants.DAILY_VALUE_POTASSIUM).ToString("F0"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText("Total Carbohydrates"); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" {0}g", this.totalcarbohydrate.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.totalcarbohydrate * 100) / Constants.DAILY_VALUE_TOTAL_CARBOHYDRATE).ToString("F0"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" Fiber {0}g", this.fiber.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.fiber * 100) / Constants.DAILY_VALUE_DIETARY_FIBER).ToString("F0"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("Sugar {0}g", this.sugar.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.Font.Bold = 1; objWord.Selection.TypeText("Protein"); objWord.Selection.Font.Bold = 0; objWord.Selection.TypeText(String.Format(" {0}g", this.protein.ToString("F2"))); objWord.Selection.MoveRight(Microsoft.Office.Interop.Word.WdUnits.wdCell, 1); objWord.Selection.TypeText(String.Format("{0}%", ((this.protein * 100) / Constants.DAILY_VALUE_PROTEIN).ToString("F0"))); objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); clsWord.AddHalfSpaceLineAtEndOfDocument(); } private void WordDocAddAllTips(Microsoft.Office.Interop.Word.Application objWord) { if (this.recipeTips.Count > 0) { objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 1, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Cells[1].LeftPadding = 0; objWord.Selection.Tables[1].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt; objWord.Selection.Font.Bold = 1; objWord.Selection.Font.Size = clsWord.WORD_RECIPE_SECTION_HEADING_FONT_SIZE; objWord.Selection.TypeText("Tips"); objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); foreach (var recipeTip in this.recipeTips) { if (recipeTip.isHeading) { objWord.Selection.Font.Bold = 1; } else { objWord.Selection.Font.Bold = 0; } objWord.Selection.TypeText(recipeTip.tipText); objWord.Selection.TypeParagraph(); objWord.Selection.Font.Bold = 0; } clsWord.AddHalfSpaceLineAtEndOfDocument(); } } private void WordDocAddSourceInfo(Microsoft.Office.Interop.Word.Application objWord) { if (!String.IsNullOrWhiteSpace(this.source) || !String.IsNullOrWhiteSpace(this.webpage) || !String.IsNullOrWhiteSpace(this.copyright)) { objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.ActiveDocument.Tables.Add(objWord.Selection.Range, 1, 1, Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior, Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent); objWord.Selection.Tables[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent; objWord.Selection.Tables[1].PreferredWidth = 100F; objWord.Selection.Cells[1].LeftPadding = 0; objWord.Selection.Tables[1].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle; objWord.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt; objWord.Selection.Font.Bold = 1; objWord.Selection.Font.Size = clsWord.WORD_RECIPE_SECTION_HEADING_FONT_SIZE; objWord.Selection.TypeText("Source"); objWord.Selection.Font.Bold = 0; objWord.Selection.Font.Size = clsWord.WORD_NORMAL_FONT_SIZE; objWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory); clsWord.AddHalfSpaceLineAtEndOfDocument(); if (!String.IsNullOrWhiteSpace(this.source)) { objWord.Selection.TypeText("Source: " + this.source); objWord.Selection.TypeParagraph(); } if (!String.IsNullOrWhiteSpace(this.webpage)) { objWord.Selection.TypeText("Web Page: " + this.webpage); objWord.Selection.TypeParagraph(); } if (!String.IsNullOrWhiteSpace(this.copyright)) { objWord.Selection.TypeText("Copyright: " + this.copyright); objWord.Selection.TypeParagraph(); } clsWord.AddHalfSpaceLineAtEndOfDocument(); } } public void JRJRTestNutritionRecalc(ref String originalNutrition, ref String recalcNutrition) { Recipe recipeClone = (Recipe)this.Clone(); recipeClone.CalcNutrition(); originalNutrition = this.JRJRTestDumpForCompare(); recalcNutrition = recipeClone.JRJRTestDumpForCompare(); } public string JRJRTestDumpForCompare() { StringBuilder strbResult = new StringBuilder(); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "---------------------------------------------------------------" + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "recipename" + Constants.TAB +this.recipename.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "recipeID" + Constants.TAB +this.recipeID.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "cookbookID" + Constants.TAB +this.cookbookID.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "cookbookchapterID" + Constants.TAB + (this.cookbookchapterID ?? Guid.Empty).ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "author" + Constants.TAB +this.author.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "source" + Constants.TAB +this.source.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "webpage" + Constants.TAB +this.webpage.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "comments" + Constants.TAB +this.comments.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "copyright" + Constants.TAB +this.copyright.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "servings" + Constants.TAB +this.servings.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "nutritionservinglabel" + Constants.TAB +this.nutritionservinglabel.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "yield" + Constants.TAB +this.yield.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "preparationtime" + Constants.TAB +this.preparationtime.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "cookingtime" + Constants.TAB +this.cookingtime.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "readyintime" + Constants.TAB +this.readyintime.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "inactivetime" + Constants.TAB +this.inactivetime.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "oventemperaturec" + Constants.TAB +this.oventemperaturec.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "oventemperaturef" + Constants.TAB +this.oventemperaturef.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "percentcaloriesfromalcohol" + Constants.TAB +this.percentcaloriesfromalcohol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "percentcaloriesfromcarbs" + Constants.TAB +this.percentcaloriesfromcarbs.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "percentcaloriesfromfat" + Constants.TAB +this.percentcaloriesfromfat.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "percentcaloriesfromprotein" + Constants.TAB +this.percentcaloriesfromprotein.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "alanine" + Constants.TAB +this.alanine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "alcohol" + Constants.TAB +this.alcohol.ToString() + Constants.CRLF); //strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "alcoholfactor" + Constants.TAB +this.alcoholfactor.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "alphacarotene" + Constants.TAB +this.alphacarotene.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "alphalinolenicacid" + Constants.TAB +this.alphalinolenicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "arachidonicacid" + Constants.TAB +this.arachidonicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "arginine" + Constants.TAB +this.arginine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "ash" + Constants.TAB +this.ash.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "asparticacid" + Constants.TAB +this.asparticacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "betacarotene" + Constants.TAB +this.betacarotene.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "betacryptoxanthin" + Constants.TAB +this.betacryptoxanthin.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "betasitosterol" + Constants.TAB +this.betasitosterol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "betatocopherol" + Constants.TAB +this.betatocopherol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "biotin" + Constants.TAB +this.biotin.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "caffeine" + Constants.TAB +this.caffeine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "calcium" + Constants.TAB +this.calcium.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "calories" + Constants.TAB +this.calories.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "caloriesfromalcohol" + Constants.TAB +this.caloriesfromalcohol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "caloriesfromcarbs" + Constants.TAB +this.caloriesfromcarbs.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "caloriesfromfat" + Constants.TAB +this.caloriesfromfat.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "caloriesfromprotein" + Constants.TAB +this.caloriesfromprotein.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "campesterol" + Constants.TAB +this.campesterol.ToString() + Constants.CRLF); //strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "carbohydratefactor" + Constants.TAB +this.carbohydratefactor.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "chloride" + Constants.TAB +this.chloride.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "cholesterol" + Constants.TAB +this.cholesterol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "choline" + Constants.TAB +this.choline.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "chromium" + Constants.TAB +this.chromium.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "copper" + Constants.TAB +this.copper.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "cystine" + Constants.TAB +this.cystine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "deltatocopherol" + Constants.TAB +this.deltatocopherol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "dihomogammalinolenicacid" + Constants.TAB +this.dihomogammalinolenicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "docosahexaenoicacid" + Constants.TAB +this.docosahexaenoicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "docosapentaenoicacid" + Constants.TAB +this.docosapentaenoicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "eicosadienoicacid" + Constants.TAB +this.eicosadienoicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "eicosapentaenoicacid" + Constants.TAB +this.eicosapentaenoicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "energy" + Constants.TAB +this.energy.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "energyfromalcohol" + Constants.TAB +this.energyfromalcohol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "energyfromcarbs" + Constants.TAB +this.energyfromcarbs.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "energyfromfat" + Constants.TAB +this.energyfromfat.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "energyfromprotein" + Constants.TAB +this.energyfromprotein.ToString() + Constants.CRLF); //strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "fatfactor" + Constants.TAB +this.fatfactor.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "fiber" + Constants.TAB +this.fiber.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "fluoride" + Constants.TAB +this.fluoride.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "folate" + Constants.TAB +this.folate.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "fructose" + Constants.TAB +this.fructose.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "galactose" + Constants.TAB +this.galactose.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "gammalinolenicacid" + Constants.TAB +this.gammalinolenicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "gammatocopherol" + Constants.TAB +this.gammatocopherol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "glucose" + Constants.TAB +this.glucose.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "glutamicacid" + Constants.TAB +this.glutamicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "glycine" + Constants.TAB +this.glycine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "histidine" + Constants.TAB +this.histidine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "hydroxyproline" + Constants.TAB +this.hydroxyproline.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "iodine" + Constants.TAB +this.iodine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "iron" + Constants.TAB +this.iron.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "isoleucine" + Constants.TAB +this.isoleucine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "lactose" + Constants.TAB +this.lactose.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "leucine" + Constants.TAB +this.leucine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "linoleicacid" + Constants.TAB +this.linoleicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "lycopene" + Constants.TAB +this.lycopene.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "lysine" + Constants.TAB +this.lysine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "magnesium" + Constants.TAB +this.magnesium.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "maltose" + Constants.TAB +this.maltose.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "manganese" + Constants.TAB +this.manganese.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "mass" + Constants.TAB +this.mass.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "methionine" + Constants.TAB +this.methionine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "molybdenum" + Constants.TAB +this.molybdenum.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfat" + Constants.TAB +this.monounsaturatedfat.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_14_1" + Constants.TAB +this.monounsaturatedfattyacid_14_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_15_1" + Constants.TAB +this.monounsaturatedfattyacid_15_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_16_1" + Constants.TAB +this.monounsaturatedfattyacid_16_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_17_1" + Constants.TAB +this.monounsaturatedfattyacid_17_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_18_1" + Constants.TAB +this.monounsaturatedfattyacid_18_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_20_1" + Constants.TAB +this.monounsaturatedfattyacid_20_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_22_1" + Constants.TAB +this.monounsaturatedfattyacid_22_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "monounsaturatedfattyacid_24_1" + Constants.TAB +this.monounsaturatedfattyacid_24_1.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "netcarbohydrates" + Constants.TAB +this.netcarbohydrates.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "niacin" + Constants.TAB +this.niacin.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "omega3fattyacids" + Constants.TAB +this.omega3fattyacids.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "omega6fattyacids" + Constants.TAB +this.omega6fattyacids.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "pantothenicacid" + Constants.TAB +this.pantothenicacid.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "phenylalanine" + Constants.TAB +this.phenylalanine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "phosphorus" + Constants.TAB +this.phosphorus.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "phytosterols" + Constants.TAB +this.phytosterols.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfat" + Constants.TAB +this.polyunsaturatedfat.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfattyacid_18_2" + Constants.TAB +this.polyunsaturatedfattyacid_18_2.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfattyacid_18_3" + Constants.TAB +this.polyunsaturatedfattyacid_18_3.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfattyacid_18_4" + Constants.TAB +this.polyunsaturatedfattyacid_18_4.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfattyacid_20_3" + Constants.TAB +this.polyunsaturatedfattyacid_20_3.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfattyacid_20_4" + Constants.TAB +this.polyunsaturatedfattyacid_20_4.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfattyacid_21_5" + Constants.TAB +this.polyunsaturatedfattyacid_21_5.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "polyunsaturatedfattyacid_22_4" + Constants.TAB +this.polyunsaturatedfattyacid_22_4.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "potassium" + Constants.TAB +this.potassium.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "proline" + Constants.TAB +this.proline.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "protein" + Constants.TAB +this.protein.ToString() + Constants.CRLF); //strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "proteinfactor" + Constants.TAB +this.proteinfactor.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "refuse" + Constants.TAB +this.refuse.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "retinol" + Constants.TAB +this.retinol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "riboflavin" + Constants.TAB +this.riboflavin.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfat" + Constants.TAB +this.saturatedfat.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_10_0" + Constants.TAB +this.saturatedfattyacid_10_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_12_0" + Constants.TAB +this.saturatedfattyacid_12_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_13_0" + Constants.TAB +this.saturatedfattyacid_13_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_14_0" + Constants.TAB +this.saturatedfattyacid_14_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_15_0" + Constants.TAB +this.saturatedfattyacid_15_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_16_0" + Constants.TAB +this.saturatedfattyacid_16_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_17_0" + Constants.TAB +this.saturatedfattyacid_17_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_18_0" + Constants.TAB +this.saturatedfattyacid_18_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_20_0" + Constants.TAB +this.saturatedfattyacid_20_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_22_0" + Constants.TAB +this.saturatedfattyacid_22_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_24_0" + Constants.TAB +this.saturatedfattyacid_24_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_4_0" + Constants.TAB +this.saturatedfattyacid_4_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_6_0" + Constants.TAB +this.saturatedfattyacid_6_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "saturatedfattyacid_8_0" + Constants.TAB +this.saturatedfattyacid_8_0.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "selenium" + Constants.TAB +this.selenium.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "serine" + Constants.TAB +this.serine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "sodium" + Constants.TAB +this.sodium.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "starch" + Constants.TAB +this.starch.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "stigmasterol" + Constants.TAB +this.stigmasterol.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "sucrose" + Constants.TAB +this.sucrose.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "sugar" + Constants.TAB +this.sugar.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "sugaralcohols" + Constants.TAB +this.sugaralcohols.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "theobromine" + Constants.TAB +this.theobromine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "thiamin" + Constants.TAB +this.thiamin.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "threonine" + Constants.TAB +this.threonine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "totalcarbohydrate" + Constants.TAB +this.totalcarbohydrate.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "totalfat" + Constants.TAB +this.totalfat.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "transfattyacids" + Constants.TAB +this.transfattyacids.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "transmonoenoicfattyacids" + Constants.TAB +this.transmonoenoicfattyacids.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "transpolyenoicfattyacids" + Constants.TAB +this.transpolyenoicfattyacids.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "tryptophan" + Constants.TAB +this.tryptophan.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "tyrosine" + Constants.TAB +this.tyrosine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "valine" + Constants.TAB +this.valine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "vitamina" + Constants.TAB +this.vitamina.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "vitaminb12" + Constants.TAB +this.vitaminb12.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "vitaminb6" + Constants.TAB +this.vitaminb6.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "vitaminc" + Constants.TAB +this.vitaminc.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "vitamind" + Constants.TAB +this.vitamind.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "vitamine" + Constants.TAB +this.vitamine.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "vitamink" + Constants.TAB +this.vitamink.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "volume" + Constants.TAB +this.volume.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "water" + Constants.TAB +this.water.ToString() + Constants.CRLF); strbResult.Append(this.cookbookID.ToString() + Constants.TAB + this.recipename + Constants.TAB + "zinc" + Constants.TAB +this.zinc.ToString() + Constants.CRLF); return strbResult.ToString(); } public object Clone() { var copy = (Recipe)(this.MemberwiseClone()); var originalIngredient = copy.recipeIngredients; copy.recipeIngredients = new List(); foreach (var ingredient in originalIngredient) { var newIngredient = (RecipeIngredient)(ingredient.Clone()); copy.recipeIngredients.Add(newIngredient); } var originalProcedures = copy.recipeProcedures; copy.recipeProcedures = new List(); foreach (var procedure in originalProcedures) { var newProcedure = (RecipeProcedure)(procedure.Clone()); copy.recipeProcedures.Add(newProcedure); } var originalTips = copy.recipeTips; copy.recipeTips = new List(); foreach(var tip in originalTips) { var newTip = (RecipeTip)(tip.Clone()); copy.recipeTips.Add(newTip); } return copy; } } }