Esempio n. 1
0
        public bool Delete(RS.ResourceStructure resoureStruc)
        {
            Contract.Requires(resoureStruc != null);
            Contract.Requires(resoureStruc.Id >= 0);

            bool deleted = false;

            if (resoureStruc.ResourceAttributeUsages != null)
            {
                using (var rsaManager = new ResourceStructureAttributeManager())
                {
                    deleted = rsaManager.DeleteUsagesByRSId(resoureStruc.Id);
                }
            }
            else
            {
                deleted = true;
            }

            if (deleted)
            {
                using (IUnitOfWork uow = this.GetUnitOfWork())
                {
                    IRepository <RS.ResourceStructure> repoStruc = uow.GetRepository <RS.ResourceStructure>();

                    resoureStruc = repoStruc.Reload(resoureStruc);
                    repoStruc.Delete(resoureStruc);

                    uow.Commit();
                }
                return(true);
            }

            return(false);
        }
        public ResourceStructureParentChoosingModel(RSE.ResourceStructure resourceStructure)
        {
            RsId        = resourceStructure.Id;
            Name        = resourceStructure.Name;
            Description = resourceStructure.Description;
            Locked      = false;

            using (ResourceStructureAttributeManager rsaManager = new ResourceStructureAttributeManager())
            {
                List <ResourceAttributeUsage>          usages = rsaManager.GetResourceStructureAttributeUsagesByRSId(resourceStructure.Id);
                List <ResourceStructureAttributeModel> list   = new List <ResourceStructureAttributeModel>();
                List <string> listNames = new List <string>();
                if (usages != null)
                {
                    foreach (ResourceAttributeUsage usage in usages)
                    {
                        list.Add(new ResourceStructureAttributeModel(usage.ResourceStructureAttribute));
                    }
                }


                if (list != null)
                {
                    listNames = list.Select(e => e.AttributeName).ToList();
                }

                ResourceStructureAttributesNames = listNames;
            }
        }
        public ResourceStructureModel Convert(RSE.ResourceStructure resourceStructure)
        {
            using (ResourceStructureAttributeManager rsaManager = new ResourceStructureAttributeManager())
            {
                List <ResourceAttributeUsage> usages             = rsaManager.GetResourceStructureAttributeUsagesByRSId(resourceStructure.Id);
                List <ResourceStructureAttributeUsageModel> list = new List <ResourceStructureAttributeUsageModel>();

                if (usages != null)
                {
                    foreach (ResourceAttributeUsage usage in usages)
                    {
                        list.Add(new ResourceStructureAttributeUsageModel(usage.Id));
                    }
                }

                return(new ResourceStructureModel()
                {
                    Id = resourceStructure.Id,
                    Name = resourceStructure.Name,
                    Description = resourceStructure.Description,
                    ResourceStructureAttributeUsages = list,
                    //Children = resourceStructure.Children.ToList()
                    //Parent = new ResourceStructureModel(resourceStructure.Parent),
                    SelectedItem = new ResourceStructureAttributeModel(),
                    AllResourceStructures = new List <ResourceStructureModel>()
                });
            }
        }
 public ResourceAttributeUsageModel(RS.ResourceAttributeUsage resourceAttributeUsage)
 {
     Id = resourceAttributeUsage.Id;
     IsValueOptional            = resourceAttributeUsage.IsValueOptional;
     ResourceStructureAttribute = resourceAttributeUsage.ResourceStructureAttribute;
     ResourceStructure          = resourceAttributeUsage.ResourceStructure;
     IsFileDataType             = resourceAttributeUsage.IsFileDataType;
 }
        //public R.ResourceClassifier ResourceClassifier { get; set; }

        public ResourceModel()
        {
            Name              = "";
            Description       = "";
            ResourceStatus    = Status.created;
            ResourceStructure = new RS.ResourceStructure();
            ResourceStructureAttributeValue = new List <ResourceStructureAttributeValueModel>();
            //ResourceClassifier = new R.ResourceClassifier();
            TimeUnits = Enum.GetValues(typeof(SystemDefinedUnit)).Cast <SystemDefinedUnit>().ToList();
            Color     = "";
        }
Esempio n. 6
0
        public RS.ResourceStructure Update(RS.ResourceStructure resourceStructure)
        {
            Contract.Requires(resourceStructure != null);

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <RS.ResourceStructure> repo = uow.GetRepository <RS.ResourceStructure>();
                repo.Merge(resourceStructure);
                var merged = repo.Get(resourceStructure.Id);
                repo.Put(merged); uow.Commit();
            }

            return(resourceStructure);
        }
        public ResourceStructureModel(RSE.ResourceStructure resourceStructure)
        {
            Id                               = resourceStructure.Id;
            Name                             = resourceStructure.Name;
            Description                      = resourceStructure.Description;
            AllResourceStructures            = new List <ResourceStructureModel>();
            ResourceStructureAttributeUsages = new List <ResourceStructureAttributeUsageModel>();

            using (ResourceStructureManager rManager = new ResourceStructureManager())
                using (ResourceStructureAttributeManager rsaManager = new ResourceStructureAttributeManager())
                {
                    if (resourceStructure.Parent != null)
                    {
                        RSE.ResourceStructure parent = rManager.GetResourceStructureById(resourceStructure.Parent.Id);
                        Parent = Convert(parent);
                        //Get Parent attributes(usages) and add it to ResourceStructureAttributeUsages List
                        List <ResourceAttributeUsage> parentUsages = rsaManager.GetResourceStructureAttributeUsagesByRSId(Parent.Id);
                        if (parentUsages.Count > 0)
                        {
                            foreach (ResourceAttributeUsage usage in parentUsages)
                            {
                                ResourceStructureAttributeUsages.Add(new ResourceStructureAttributeUsageModel(usage.Id, usage.ResourceStructureAttribute.Id, Parent.Name));
                            }
                        }
                    }
                    else
                    {
                        Parent = null;
                    }


                    List <ResourceAttributeUsage> usages = rsaManager.GetResourceStructureAttributeUsagesByRSId(resourceStructure.Id);

                    if (usages.Count > 0)
                    {
                        foreach (ResourceAttributeUsage usage in usages)
                        {
                            ResourceStructureAttributeUsages.Add(new ResourceStructureAttributeUsageModel(usage.Id, usage.ResourceStructureAttribute.Id, null));
                        }
                    }

                    SelectedItem = new ResourceStructureAttributeModel();
                }
        }
        public ResourceStructureManagerModel(RSE.ResourceStructure resourceStructure)
        {
            Id           = resourceStructure.Id;
            Name         = resourceStructure.Name;
            Description  = resourceStructure.Description;
            InUse        = false;
            EditAccess   = false;
            DeleteAccess = false;

            using (ResourceStructureManager rManager = new ResourceStructureManager())
                using (ResourceStructureAttributeManager rsaManager = new ResourceStructureAttributeManager())
                {
                    if (resourceStructure.Parent != null)
                    {
                        RSE.ResourceStructure parent = rManager.GetResourceStructureById(resourceStructure.Parent.Id);
                        Parent = parent.Name;
                    }
                    else
                    {
                        Parent = "";
                    }

                    List <ResourceAttributeUsage>      usages = rsaManager.GetResourceStructureAttributeUsagesByRSId(resourceStructure.Id);
                    List <ResourceAttributeUsageModel> list   = new List <ResourceAttributeUsageModel>();
                    List <string> listNames = new List <string>();
                    if (usages != null)
                    {
                        foreach (ResourceAttributeUsage usage in usages)
                        {
                            list.Add(new ResourceAttributeUsageModel(usage));
                        }
                    }


                    if (list != null)
                    {
                        listNames = list.Select(e => e.ResourceStructureAttribute.Name).ToList();
                    }

                    ResourceStructureAttributesNames = listNames;
                }
        }
Esempio n. 9
0
        public RS.ResourceStructure Create(string name, string description, List <RS.ResourceAttributeUsage> resourceAttributeUsage, RS.ResourceStructure parent)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(name));
            Contract.Requires(!String.IsNullOrWhiteSpace(description));

            RS.ResourceStructure resourceStructure = new RS.ResourceStructure()
            {
                ResourceAttributeUsages = resourceAttributeUsage,
                Parent      = parent,
                Name        = name,
                Description = description
            };

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <RS.ResourceStructure> repo = uow.GetRepository <RS.ResourceStructure>();
                repo.Put(resourceStructure);
                uow.Commit();
            }

            return(resourceStructure);
        }
        public RS.ResourceAttributeUsage CreateResourceAttributeUsage(RS.ResourceStructureAttribute rsa, RS.ResourceStructure rs, bool isOptional, bool isFileDataType)
        {
            RS.ResourceAttributeUsage resourceAttributeUsage = new RS.ResourceAttributeUsage()
            {
                Label                      = rsa.Name,
                ResourceStructure          = rs,
                ResourceStructureAttribute = rsa,
                IsValueOptional            = isOptional,
                IsFileDataType             = isFileDataType
            };

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <RS.ResourceAttributeUsage> repo = uow.GetRepository <RS.ResourceAttributeUsage>();
                repo.Put(resourceAttributeUsage);
                uow.Commit();
            }

            return(resourceAttributeUsage);
        }
Esempio n. 11
0
        public R.SingleResource CreateResource(string name, string description, int quantity, string color, bool withActivity, RS.ResourceStructure resourceStructure,
                                               TimeDuration duration)
        {
            //default status is created. In this status it is not visible.
            Status   status           = Status.created;
            DateTime statusChangeDate = DateTime.Now;

            R.SingleResource resource = new R.SingleResource(resourceStructure);

            //resource.BookingTimeGranularity = bookingTimeGranularity;


            resource.Name             = name;
            resource.Description      = description;
            resource.Quantity         = quantity;
            resource.ResourceStatus   = status;
            resource.Duration         = duration;
            resource.Color            = color;
            resource.WithActivity     = withActivity;
            resource.StatusChangeDate = statusChangeDate;
            resource.ResourceStatus   = status;

            //bookingTimeGranularity.Resource = resource;

            //bookingTimeGranularity.Resource = resource;

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <R.SingleResource> repo = uow.GetRepository <R.SingleResource>();
                //IRepository<R.BookingTimeGranularity> repoB = uow.GetRepository<R.BookingTimeGranularity>();
                //resource.BookingTimeGranularity = this.CreateBookingTimeGranularity(bookingTimeGranularity.Duration, bookingTimeGranularity.LargeUnitOfTime, bookingTimeGranularity.StartTime);
                //repoB.Put(bookingTimeGranularity);
                repo.Put(resource);
                uow.Commit();
            }

            return(resource);
        }