예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TopRecipeID = new RecipeDB().getTopRecipe();
        if (TopRecipeID != 0)
        {
            TopRecipeDiv.Visible = true;
            RecipeClass TopRecipeClass = new RecipeDB().GetRecipe(TopRecipeID);
            TopRecipeName = TopRecipeClass.RecipeName;
            TopRecipeImage = TopRecipeClass.ImagePath;
        }
        else
            TopRecipeDiv.Visible = false;

        DataTable AllRecipesTable = (new RecipeDB()).GetLatestRecipes();

        if (AllRecipesTable.Rows.Count > 0)
        {
            DataView ListView = new DataView();
            ListView.Table = AllRecipesTable;
            AllRecipeList.DataSource = ListView;
        }

        DataTable LatestArticles = new ArticleDB().GetLatestArticles();
        ArticlesRepeater.DataSource = LatestArticles;

        this.DataBind();
    }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     DataTable RecipeTable = new RecipeDB().AllVerifiedRecipes();
     TopRecipeList.DataSource = RecipeTable;
     TopRecipeList.DataTextField = "RecipeName";
     TopRecipeList.DataValueField = "RecipeID";
     TopRecipeList.DataBind();
 }
예제 #3
0
        private void LoadRecipes()
        {
            String file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, recipesFile);

            if (File.Exists(file))
            {
                using (var streamReader = new StreamReader(file))
                {
                    using (var jsonTextReader = new JsonTextReader(streamReader))
                    {
                        JToken token = JObject.ReadFrom(jsonTextReader);
                        for (int i = 0; i < token.Count(); i++)
                        {
                            Recipe r = new Recipe()
                            {
                                Id            = token[i]["ID"].ToObject <int>(),
                                ExternalId    = token[i]["ExternalID"].ToObject <int>(),
                                DataId        = token[i]["DataID"].ToObject <int>(),
                                Name          = token[i]["Name"].ToObject <String>(),
                                Rating        = token[i]["Rating"].ToObject <int>(),
                                Type          = token[i]["Type"].ToObject <int>(),
                                Quantity      = token[i]["Count"].ToObject <int>(),
                                CreatedItemId = token[i]["CreatedItemId"].ToObject <int>()
                            };

                            for (int j = 0; j < token[i]["Ingredients"].Count(); j++)
                            {
                                Recipe ingredients = new Recipe()
                                {
                                    ItemId   = token[i]["Ingredients"][j]["ItemID"].ToObject <int>(),
                                    Quantity = token[i]["Ingredients"][j]["Count"].ToObject <int>(),
                                };

                                int dataId = ItemIdToDataId[ingredients.ItemId];
                                //SlimItem item = DataIdToSlimItem[dataId];
                                ingredients.DataId = dataId;

                                r.RecipeItems.Add(ingredients);
                            }

                            if (!CreatedIdToRecipe.ContainsKey(r.CreatedItemId))
                            {
                                CreatedIdToRecipe.Add(r.CreatedItemId, r);
                            }

                            RecipeIdToRecipe.Add(r.Id, r);

                            RecipeDB.Add(r);
                        }
                    }
                }
            }

            if (RecipesLoaded != null)
            {
                RecipesLoaded(this, new EventArgs());
            }
        }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     contentPanel = transform.GetChild(0).GetChild(0).transform;
     recipeDB     = GameObject.FindGameObjectWithTag("RecipeDB").GetComponent <RecipeDB>();
     recipeList   = recipeDB.GetRecipeList <CraftRecipe>();
     inventory    = playerInventory.GetComponent <Inventory>();
     input        = craftingInput.GetComponent <Inventory>();
     AddButtons();
 }
예제 #5
0
 private void Start()
 {
     button.onClick.AddListener(Craft);
     itemDB     = GameObject.FindGameObjectWithTag("ItemDB").transform.GetComponent <ItemDB>();
     recipeDB   = transform.parent.GetChild(0).GetComponent <RecipeDB>();
     recipeList = recipeDB.GetRecipeList <CraftRecipe>();
     Input      = transform.parent.GetChild(2).GetComponent <Inventory>();
     Output     = transform.parent.GetChild(3).GetComponent <Inventory>();
 }
예제 #6
0
    protected void UploadRecipe_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            RecipeClass recipeObject;
            RecipeDB recipeDatabase = new RecipeDB();

            if (PhotoUpload.HasFile)
            {
                string FileName = Path.GetFileName(PhotoUpload.PostedFile.FileName);
                string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(PhotoUpload.PostedFile.FileName);
                string FileExtension = Path.GetExtension(PhotoUpload.PostedFile.FileName);

                string FolderPath = "~\\UserFiles\\" + User.Identity.Name.ToString();
                if (!Directory.Exists(FolderPath))
                    Directory.CreateDirectory(Server.MapPath(FolderPath));

                string ImagePath = string.Concat(FolderPath, "\\", FileName);

                int i = 1;
                while(File.Exists(Server.MapPath(ImagePath)))
                {
                    ImagePath = string.Concat(FolderPath, "\\", FileNameWithoutExtension,i.ToString(),FileExtension);
                    i++;
                }

                PhotoUpload.SaveAs(Server.MapPath(ImagePath));

                recipeObject = new RecipeClass(RecipeCategory.SelectedItem.Value, RecipeName.Text,
                    User.Identity.Name, Ingredients.Text, Directions.Text, int.Parse(PreparationTime.Text), ImagePath);
            }
            else
            {
                string ImagePath = "~\\Images\\noimage.jpg";
                recipeObject = new RecipeClass(RecipeCategory.SelectedItem.Value, RecipeName.Text,
                    User.Identity.Name, Ingredients.Text, Directions.Text, int.Parse(PreparationTime.Text), ImagePath);
            }
            recipeDatabase.InsertRecipe(recipeObject);

            Response.Redirect("~\\Default.aspx");
        }
    }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        recipeDB = new RecipeDB();
        RecipeID = int.Parse(Request.QueryString["RecipeID"]);

        if (!this.IsPostBack)
        {
            if (Request.UrlReferrer != null && !new RecipeDB().isCook(RecipeID, User.Identity.Name))
            {
                if (!(Request.UrlReferrer.Query.Contains(HttpContext.Current.Request.Url.PathAndQuery)
                    || Request.UrlReferrer.AbsoluteUri == Request.Url.AbsoluteUri))
                    recipeDB.IncreaseView(RecipeID);
            }
        }

        DataTable CommentsTable = new CommentsDB().GetComments(RecipeID);
        DataView CommentsView = new DataView(CommentsTable);

        if (CommentsTable.Rows.Count != 0)
        {
            CommentsView.Sort = "PostedTime DESC";
            CommentsRepeater.DataSource = CommentsView;
            CommentsRepeater.DataBind();
            CommentsRepeater.Visible = true;
            NoCommentsLabel.Visible = false;
        }
        else
        {
            NoCommentsLabel.Visible = true;
            CommentsRepeater.Visible = false;
        }

        if (Membership.GetUser() != null)
            CommentView.SetActiveView(LoggedUserView);
        else
            CommentView.SetActiveView(NoUserView);

        ClickHere.NavigateUrl = @"~\Account\Login.aspx?ReturnUrl=" + Page.Request.RawUrl;
    }
예제 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        RecipeID = int.Parse(Request.QueryString["ID"]);
        user = User.Identity.Name;

        RecipeClass Recipe = new RecipeDB().GetRecipe(RecipeID);

        if (Recipe.Cook != user)
            throw new InvalidOperationException();

        RecipeName = Recipe.RecipeName;
        Category = Recipe.RecipeCategory;
        PreparationTime = Recipe.PreparationTime;

        RecipeImage.ImageUrl = Recipe.ImagePath;

        if (!this.IsPostBack)
        {
            string[] newLineDelim = { Environment.NewLine };

            string[] _Ingredients = Recipe.Ingredients.Split(newLineDelim, StringSplitOptions.RemoveEmptyEntries);
            foreach (string item in _Ingredients)
            {
                IngredientsTxt.Text += item;
                IngredientsTxt.Text += Environment.NewLine;
            }

            string[] _Directions = Recipe.Directions.Split(newLineDelim, StringSplitOptions.RemoveEmptyEntries);
            foreach (string item in _Directions)
            {
                DirectionsTxt.Text += item;
                DirectionsTxt.Text += Environment.NewLine;
            }
        }
        this.DataBind();
    }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     recipeDB = GameObject.FindGameObjectWithTag("RecipeDB").transform.GetComponent <RecipeDB>();
     Input    = ovenCraftInterface.transform.Find("Input").GetComponent <Inventory>();
 }
예제 #10
0
 public void AddRecipeToRecipeDB()
 {
     database = recipeDB.GetComponent <RecipeDB>();
     database.InsertRecipe(recipe, databaseName);
 }
예제 #11
0
 public void RemoveRecipeFromRecipeDB()
 {
     database = recipeDB.GetComponent <RecipeDB>();
     database.RemoveRecipe(recipe, databaseName);
 }