示例#1
0
        // GET: Resource
        public ActionResult Index()
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                ResourceAvailable model = new ResourceAvailable();

                model.ResourceAvailableList = ResourceHelperService.ResourceListItems().Result;
                model.ResourceAvailableList = model.ResourceAvailableList.OrderBy(w => w.Warehouse).OrderBy(x => x.ResourceName).ToList();
                //model.Projectlist = new SelectList(TimeSheetAPIHelperService.CostModelProject().Result, "ID", "Value");



                return(View(model));
            }
        }
示例#2
0
        /// <summary>Retorna o custo de um recurso num outro recurso</summary>
        private bool getResourceCost(ResourceInfo resources, string originalRes, string costResCategory, string costRes, out int amount)
        {
            ResourceFactory factory = resources.getAvailableFactory(originalRes);

            amount = 0;

            if (factory.CostActions == null)
            {
                return(true);
            }

            foreach (Action action in factory.CostActions)
            {
                if (action is ResourceNeeded)
                {
                    ResourceNeeded needed = (ResourceNeeded)action;
                    //Chronos.Utils.Log.log("needed.Value=" + needed.Value + " needed.Key=" +  needed.Key + " res=" + costRes);
                    if (needed.Key == costRes)
                    {
                        amount = needed.Quantity;
                        return(needed.Quantity <= Manager.getResourceCount(costResCategory, costRes));
                    }
                }
                else
                {
                    if (action is ResourceAvailable)
                    {
                        ResourceAvailable avail = (ResourceAvailable)action;
                        if (avail.Value == costRes)
                        {
                            amount = avail.Quantity;
                            return(avail.Quantity <= Manager.getResourceCount(costResCategory, costRes));
                        }
                    }
                }
            }

            return(true);
        }