public ActionResult ResourceStructureParent_Select(long rsId)
        {
            using (ResourceStructureManager rsManager = new ResourceStructureManager())
            {
                IQueryable <ResourceStructure> data = rsManager.GetAllResourceStructures();

                //List<ResourceStructureModel> resourceStructures = new List<ResourceStructureModel>();
                List <ResourceStructureParentChoosingModel> resourceStructures = new List <ResourceStructureParentChoosingModel>();

                foreach (ResourceStructure rs in data)
                {
                    if (rs.Id != rsId)
                    {
                        ResourceStructureParentChoosingModel temp = new ResourceStructureParentChoosingModel(rs);
                        temp.Locked   = this.CheckParentPossibility(rsId, rs.Id);
                        temp.RsId     = rsId;
                        temp.ParentId = rs.Id;
                        resourceStructures.Add(temp);
                    }
                }

                return(View("_chooseResourceStructure", new GridModel <ResourceStructureParentChoosingModel> {
                    Data = resourceStructures
                }));
            }
        }
        //Default Constructor
        public EditResourceModel()
        {
            ResourceStructures = new List <ResourceStructureModel>();

            ResourceStructureAttributeValues = new List <ResourceStructureAttributeValueModel>();
            TextValues = new List <Models.ResourceStructure.TextValueModel>();
            FileValues = new List <Models.ResourceStructure.FileValueModel>();

            using (ResourceStructureManager manager = new ResourceStructureManager()){
                Parent = new ResourceModel();
                foreach (RS.ResourceStructure rs in manager.GetAllResourceStructures().ToList())
                {
                    ResourceStructures.Add(new ResourceStructureModel(rs));
                }

                //BookingTimeGranularity
                Duration       = new TimeDuration();
                Duration.Value = 1;
                TimeUnits      = Enum.GetValues(typeof(SystemDefinedUnit)).Cast <SystemDefinedUnit>().ToList();


                ResourceConstraintModel = new ResourceConstraintModel();
                ResourceConstraints     = new List <ResourceConstraintModel>();
                DependencyConstraints   = new List <DependencyConstraintModel>();
                BlockingConstraints     = new List <BlockingConstraintModel>();
                QuantityConstraints     = new List <QuantityConstraintModel>();
            }
        }
        public ActionResult ChooseResourceStructureAttributes(long id)
        {
            ViewData["RSID"] = id;

            List <ResourceStructureParentChoosingModel> model = new List <ResourceStructureParentChoosingModel>();

            using (ResourceStructureManager rsManager = new ResourceStructureManager())
            {
                IQueryable <ResourceStructure> data = rsManager.GetAllResourceStructures();

                foreach (ResourceStructure rs in data)
                {
                    if (rs.Id != id)
                    {
                        ResourceStructureParentChoosingModel temp = new ResourceStructureParentChoosingModel(rs);
                        temp.Locked   = this.CheckParentPossibility(id, rs.Id);
                        temp.RsId     = id;
                        temp.ParentId = rs.Id;
                        model.Add(temp);
                    }
                }
            }

            return(PartialView("_chooseResourceStructureAttributes", model));
        }
        //public List<RSE.ResourceStructure> Children { get; set; }

        public void FillRSM()
        {
            using (ResourceStructureManager m = new ResourceStructureManager())
            {
                List <RSE.ResourceStructure> list = m.GetAllResourceStructures().ToList();
                foreach (RSE.ResourceStructure r in list)
                {
                    this.AllResourceStructures.Add(Convert(r));
                }
            }
        }
Example #5
0
        public ActionResult TreeFilterSchedules()
        {
            ResourceFilterModel model = new ResourceFilterModel();

            using (ResourceStructureManager rsManager = new ResourceStructureManager())
            //   using(ResourceManager rManager = new ResourceManager())
            {
                // List<SingleResource> singleResources = rManager.GetAllReesources().ToList();


                // List<ResourceModel> resources = new List<ResourceModel>();
                // singleResources.ForEach(r => resources.Add(new ResourceModel(r)));
                List <ResourceStructure> resourceStructures = rsManager.GetAllResourceStructures().ToList();

                foreach (ResourceStructure rs in resourceStructures)
                {
                    foreach (ResourceAttributeUsage usage in rs.ResourceAttributeUsages)
                    {
                        ResourceStructureAttribute attr = usage.ResourceStructureAttribute;
                        AttributeDomainItemsModel  item = new AttributeDomainItemsModel(attr);
                        if (item.DomainItems.Count != 0)
                        {
                            if (!model.TreeItems.Any(a => a.AttrId == item.AttrId))
                            {
                                model.TreeItems.Add(item);
                            }
                        }
                    }
                }

                /*foreach (ResourceModel r in resources)
                 * {
                 *  foreach (ResourceAttributeUsage usage in r.ResourceStructure.ResourceAttributeUsages)
                 *  {
                 *      ResourceStructureAttribute attr = usage.ResourceStructureAttribute;
                 *      AttributeDomainItemsModel item = new AttributeDomainItemsModel(attr);
                 *      if (item.DomainItems.Count != 0)
                 *      {
                 *          if (!model.TreeItems.Any(a => a.AttrId == item.AttrId))
                 *              model.TreeItems.Add(item);
                 *      }
                 *  }
                 * }*/
            }

            return(PartialView("_treeFilterSchedules", model));
        }
        public ActionResult ResourceStructure_Select()
        {
            using (var rsManager = new ResourceStructureManager())
                using (var permissionManager = new EntityPermissionManager())
                    using (var entityTypeManager = new EntityManager())
                    {
                        IQueryable <ResourceStructure> data = rsManager.GetAllResourceStructures();

                        //List<ResourceStructureModel> resourceStructures = new List<ResourceStructureModel>();
                        List <ResourceStructureManagerModel> resourceStructures = new List <ResourceStructureManagerModel>();

                        //get id from loged in user
                        long userId = UserHelper.GetUserId(HttpContext.User.Identity.Name);
                        //get entity type id
                        long entityTypeId = entityTypeManager.FindByName("ResourceStructure").Id;

                        foreach (ResourceStructure rs in data)
                        {
                            ResourceStructureManagerModel temp = new ResourceStructureManagerModel(rs);
                            temp.InUse = rsManager.IsResourceStructureInUse(rs.Id);

                            //get permission from logged in user
                            temp.EditAccess = permissionManager.HasEffectiveRight(userId, new List <long>()
                            {
                                entityTypeId
                            }, rs.Id, RightType.Write);
                            temp.DeleteAccess = permissionManager.HasEffectiveRight(userId, new List <long>()
                            {
                                entityTypeId
                            }, rs.Id, RightType.Delete);

                            resourceStructures.Add(temp);
                        }


                        return(View("ResourceStructureManager", new GridModel <ResourceStructureManagerModel> {
                            Data = resourceStructures
                        }));
                    }
        }
        public ActionResult ResourceStructure()
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Manage Resource Structures", this.Session.GetTenant());
            List <ResourceStructureManagerModel> model = new List <ResourceStructureManagerModel>();

            using (var rsManager = new ResourceStructureManager())
                using (var permissionManager = new EntityPermissionManager())
                    using (var entityTypeManager = new EntityManager())
                    {
                        IQueryable <ResourceStructure> data = rsManager.GetAllResourceStructures();

                        //get id from loged in user
                        long userId = UserHelper.GetUserId(HttpContext.User.Identity.Name);
                        //get entity type id
                        long entityTypeId = entityTypeManager.FindByName("ResourceStructure").Id;

                        foreach (ResourceStructure rs in data)
                        {
                            ResourceStructureManagerModel temp = new ResourceStructureManagerModel(rs);
                            temp.InUse = rsManager.IsResourceStructureInUse(rs.Id);

                            //get permission from logged in user
                            temp.EditAccess = permissionManager.HasEffectiveRight(userId, new List <long>()
                            {
                                entityTypeId
                            }, rs.Id, RightType.Write);
                            temp.DeleteAccess = permissionManager.HasEffectiveRight(userId, new List <long>()
                            {
                                entityTypeId
                            }, rs.Id, RightType.Delete);

                            model.Add(temp);
                        }
                    }
            return(View("ResourceStructureManager", model));
        }
        public EditResourceModel(R.SingleResource resource, List <ResourceStructureAttributeValueModel> valuesModel, List <TextValueModel> textValues, List <FileValueModel> fileValues)
        {
            Id                = resource.Id;
            Name              = resource.Name;
            Description       = resource.Description;
            Quantity          = resource.Quantity;
            ResourceStructure = new ResourceStructureModel(resource.ResourceStructure);
            ResourceStructureAttributeValues = valuesModel;
            ResourceStructures = new List <ResourceStructureModel>();
            Color                 = resource.Color;
            WithActivity          = resource.WithActivity;
            ResourceConstraints   = new List <Resource.ResourceConstraintModel>();
            DependencyConstraints = new List <DependencyConstraintModel>();
            BlockingConstraints   = new List <BlockingConstraintModel>();
            QuantityConstraints   = new List <QuantityConstraintModel>();
            //TextValues = new List<TextValueModel>();
            //FileValues = new List<FileValueModel>();

            TextValues = textValues;
            FileValues = fileValues;

            //BookingTimeGranularity
            Duration  = new TimeDuration();
            Duration  = resource.Duration.Self;
            TimeUnits = Enum.GetValues(typeof(SystemDefinedUnit)).Cast <SystemDefinedUnit>().ToList();

            using (ResourceStructureManager manager = new ResourceStructureManager())
            {
                foreach (RS.ResourceStructure rs in manager.GetAllResourceStructures().ToList())
                {
                    ResourceStructures.Add(new ResourceStructureModel(rs));
                }
            }
            //BookingTimeGranularity = resource.BookingTimeGranularity;

            ResourceConstraintModel = new ResourceConstraintModel();

            if (resource.ResourceConstraints != null)
            {
                foreach (ResourceConstraint c in resource.ResourceConstraints)
                {
                    if (c is DependencyConstraint)
                    {
                        DependencyConstraintModel dcModel = new DependencyConstraintModel((DependencyConstraint)c);
                        dcModel.Id    = c.Id;
                        dcModel.Index = c.Index;
                        DependencyConstraints.Add(dcModel);
                        ResourceConstraints.Add(dcModel);
                    }

                    if (c is BlockingConstraint)
                    {
                        BlockingConstraintModel bcModel = new BlockingConstraintModel((BlockingConstraint)c);
                        bcModel.Id    = c.Id;
                        bcModel.Index = c.Index;
                        BlockingConstraints.Add(bcModel);
                        ResourceConstraints.Add(bcModel);
                    }

                    if (c is QuantityConstraint)
                    {
                        QuantityConstraintModel qcModel = new QuantityConstraintModel((QuantityConstraint)c);
                        qcModel.Id    = c.Id;
                        qcModel.Index = c.Index;
                        QuantityConstraints.Add(qcModel);
                        ResourceConstraints.Add(qcModel);
                    }
                }
                //Sort by Index
                ResourceConstraints = ResourceConstraints.OrderBy(x => x.Index).ToList();
            }
        }