private void Start() { TopUserInfo ui = new TopUserInfo(); //ToDo:编写创建用户的DataAccess代码 for (Int32 idx = 1; idx <= 9; idx++) { Thread.Sleep(1000); ui = new TopUserInfo() { isFinish = false, process = idx * 10, userInfo = null }; DispatcherHelper.CheckBeginInvokeOnUI(() => { Messenger.Default.Send <TopUserInfo>(ui, "UserMessenger"); }); } Thread.Sleep(1000); ui = new TopUserInfo() { isFinish = true, process = 100, userInfo = up }; DispatcherHelper.CheckBeginInvokeOnUI(() => { Messenger.Default.Send <TopUserInfo>(ui, "UserMessenger"); }); }
/// <summary> /// 创建进度 /// </summary> /// <param name="top"></param> public void FeedBack(TopUserInfo top) { if (top.isFinish) { if (top.userInfo != null) { UserList.Add(top.userInfo); } User = new UserParam(); IsEnableForm = true; IsWaitingDisplay = false; } else { ProcessRange = top.process; } }
public ActionResult ProposeRecipe() { string productName = String.Empty; if (Session[ProductModel.SessionName] != null) { productName = Session[ProductModel.SessionName].ToString(); } TopUserInfo objTUI = null; objSyncFoodContext = new SyncFoodContext(); using (IUnitOfWork unitOfWork = new UnitOfWork(objSyncFoodContext)) { FoodSync.Core.Model.Domain.User objUser = unitOfWork.Users.SingleOrDefault(u => u.UserName == User.Identity.Name); if (Session[TopUserInfo.SessionName] != null) { objTUI = Session[TopUserInfo.SessionName] as TopUserInfo; objTUI.lstRecipes = new List <RecipeModel>(); List <KitchenProduct> lstProducts = unitOfWork.Kitchens.GetProductsFromKitchen(DateTime.Today.ToShortDateString(), objUser.Id); List <int> lstOriginals = new List <int>(); foreach (var product in lstProducts) { if (lstOriginals.Contains(product.ProductId)) { continue; } lstOriginals.Add(product.ProductId); List <Recipe> lstR = unitOfWork.Recipes.GetRecipesForProduct(product.ProductId); foreach (var itemR in lstR) { RecipeModel objNewRecipe = new RecipeModel(); objNewRecipe.RecipeName = itemR.RecipeName; objNewRecipe.RecipeDescription = itemR.Instructions; objTUI.lstRecipes.Add(objNewRecipe); } } } } return(RedirectToAction("Index")); }
public ActionResult Index() { if (Request.IsAuthenticated) { objSyncFoodContext = new SyncFoodContext(); using (IUnitOfWork unitOfWork = new UnitOfWork(objSyncFoodContext)) { FoodSync.Core.Model.Domain.User objUser = unitOfWork.Users.SingleOrDefault(user => user.UserName == User.Identity.Name); if (objUser != null) { TopUserInfo objTUI = null; if (Session[TopUserInfo.SessionName] != null) { objTUI = (TopUserInfo)Session[TopUserInfo.SessionName]; } else { objTUI = new TopUserInfo(); } objTUI.Name = String.Format("{0} {1}", objUser.FirstName, objUser.LastName); objTUI.OptimalCalloriesPerDay = objUser.OptimalCalloriesPerDay; DateTime now = DateTime.Today; objTUI.Age = now.Year - objUser.DateOfBirth.Year; objTUI.Height = objUser.Height; objTUI.Weight = objUser.Weight; string[] files = Directory.GetFiles(Server.MapPath("~/Images")); if (files.Length == 1) { objTUI.ImagePath = files[0]; Python.Python objPython = new Python.Python(); string classifierPath = @"C:\Users\Vancho\Desktop\NASA Space App\Python\Food Classifier"; string recognizedProductClass = objPython.ProcessImage(files[0], "SyncFoodClassifier.py", classifierPath); string condition = "fresh"; //nemame rasipani od drugite proizvodi if (recognizedProductClass == "banana") { condition = objPython.ProcessImage(files[0], "SpoiledClassifier.py", @"C:\Users\Vancho\Desktop\NASA Space App\Python\Spoiled Classifier"); } Product objProduct = unitOfWork.Products.GetProductByName(recognizedProductClass); ProductModel objProductModel = new ProductModel(); objProductModel.Name = String.Empty; if (objProduct != null) { objProductModel.Name = objProduct.Name; objProductModel.ProductInfo = objProduct.Info; objProductModel.Callories = objProduct.Calories.ToString(); objProductModel.Season = objProduct.Season.ToString(); objProductModel.ShelfLife = objProduct.ShelfLife.ToString() + " days"; objProductModel.Condition = condition; objProductModel.CarbonFootPrint = objProduct.CarbonFootPrint.ToString(); objProductModel.Allergens = objProduct.Allergens.ToString(); objProductModel.Hazards = objProduct.Hazards.ToString(); Session[ProductModel.SessionName] = objProduct.Name; } objTUI.Product = objProductModel; objTUI.ImagePath = String.Format("~/Images/Product.jpg?t={0}", DateTime.Now.ToShortTimeString()); } //Proveri za recepti objTUI.lstRecipes = new List <RecipeModel>(); List <KitchenProduct> lstProducts = unitOfWork.Kitchens.GetProductsFromKitchen(DateTime.Today.ToShortDateString(), objUser.Id); List <int> lstOriginals = new List <int>(); foreach (var product in lstProducts) { if (lstOriginals.Contains(product.ProductId)) { continue; } lstOriginals.Add(product.ProductId); List <Recipe> lstR = unitOfWork.Recipes.GetRecipesForProduct(product.ProductId); foreach (var itemR in lstR) { RecipeModel objNewRecipe = new RecipeModel(); objNewRecipe.RecipeName = itemR.RecipeName; objNewRecipe.RecipeDescription = itemR.Instructions; objTUI.lstRecipes.Add(objNewRecipe); } } Session[TopUserInfo.SessionName] = objTUI; return(View(objTUI)); } } } return(View()); }