예제 #1
0
 public ScheduleEventModel()
 {
     //ByPerson = new PersonInSchedule();
     ForPersons            = new List <PersonInSchedule>();
     Contact               = new PersonInSchedule();
     Activities            = new List <ActivityEventModel>();
     ScheduleDurationModel = new ScheduleDurationModel();
 }
예제 #2
0
 //copy hole ScheduleDurationModel with new index
 public ScheduleDurationModel(ScheduleDurationModel scheduleDurationModel, int newIndex)
 {
     Index         = newIndex;
     StartDate     = scheduleDurationModel.StartDate;
     EndDate       = scheduleDurationModel.EndDate;
     EventId       = scheduleDurationModel.EventId;
     DurationValue = scheduleDurationModel.DurationValue;
     EditMode      = scheduleDurationModel.EditMode;
     EditAccess    = scheduleDurationModel.EditAccess;
 }
예제 #3
0
        public ScheduleEventModel(R.SingleResource resource)
        {
            ResourceId          = resource.Id;
            ResourceName        = resource.Name;
            ResourceDescription = resource.Description;
            WithActivity        = resource.WithActivity;
            ResourceQuantity    = resource.Quantity;

            ScheduleDurationModel scheduleDurationModel = new ScheduleDurationModel();

            scheduleDurationModel.DurationValue = resource.Duration.Value;
            scheduleDurationModel.TimeUnit      = resource.Duration.TimeUnit;
            ScheduleDurationModel = scheduleDurationModel;

            //ByPerson = new PersonInSchedule();
            ForPersons = new List <PersonInSchedule>();
            Contact    = new PersonInSchedule();
            Activities = new List <ActivityEventModel>();
            Files      = new List <FileValueModel>();

            //Get File to Resource if exsist
            foreach (ResourceAttributeUsage usage in resource.ResourceStructure.ResourceAttributeUsages)
            {
                if (usage.IsFileDataType)
                {
                    using (ResourceStructureAttributeManager valueManager = new ResourceStructureAttributeManager())
                    {
                        ResourceAttributeValue value = valueManager.GetValueByUsageAndResource(usage.Id, resource.Id);
                        if (value is FileValue)
                        {
                            FileValue      fileValue = (FileValue)value;
                            FileValueModel fvm       = new FileValueModel(fileValue);
                            Files.Add(fvm);
                            //if (!usage.IsValueOptional)
                            if (fvm.Data != null)
                            {
                                ResourceHasFiles = true;
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        // Copy constructor
        public ScheduleEventModel(ScheduleEventModel previousObject, int newIndex)
        {
            Index                 = newIndex;
            EventId               = previousObject.EventId;
            ResourceId            = previousObject.ResourceId;
            ResourceName          = previousObject.ResourceName;
            ResourceDescription   = previousObject.ResourceDescription;
            WithActivity          = previousObject.WithActivity;
            ScheduleDurationModel = new ScheduleDurationModel(previousObject.ScheduleDurationModel, newIndex);
            EditMode              = previousObject.EditMode;
            EditAccess            = previousObject.EditAccess;
            DeleteAccess          = previousObject.DeleteAccess;

            //create for every person object in list a new object
            List <PersonInSchedule> copyListPersons = new List <PersonInSchedule>();

            previousObject.ForPersons.ForEach(r => copyListPersons.Add(new PersonInSchedule(r, newIndex)));
            ForPersons = copyListPersons;

            //create for every activity object in list a new object
            List <ActivityEventModel> copyListActivities = new List <ActivityEventModel>();

            previousObject.Activities.ForEach(r => copyListActivities.Add(new ActivityEventModel(r, newIndex)));
            Activities = copyListActivities;

            //create for every resource attribute  object in list a new object
            List <ResourceAttributeValue> copyResourceAttributeValue = new List <ResourceAttributeValue>();

            previousObject.ResourceAttributeValues.ToList().ForEach(r => copyResourceAttributeValue.Add(r));
            ResourceAttributeValues = copyResourceAttributeValue;

            ByPerson         = previousObject.ByPerson;
            Contact          = previousObject.Contact;
            ScheduleQuantity = previousObject.ScheduleQuantity;
            ResourceQuantity = previousObject.ResourceQuantity;
            ContactName      = previousObject.ContactName;
            ResourceHasFiles = previousObject.ResourceHasFiles;
            Files            = previousObject.Files;
        }
 // Copy constructor
 public ScheduleEventModel(ScheduleEventModel previousObject, int newIndex)
 {
     Index                 = newIndex;
     EventId               = previousObject.EventId;
     ResourceId            = previousObject.ResourceId;
     ResourceName          = previousObject.ResourceName;
     ResourceDescription   = previousObject.ResourceDescription;
     WithActivity          = previousObject.WithActivity;
     ScheduleDurationModel = new ScheduleDurationModel(previousObject.ScheduleDurationModel, newIndex);
     EditMode              = previousObject.EditMode;
     EditAccess            = previousObject.EditAccess;
     DeleteAccess          = previousObject.DeleteAccess;
     ForPersons            = new List <PersonInSchedule>(previousObject.ForPersons);
     Activities            = new List <ActivityEventModel>(previousObject.Activities);
     ByPerson              = previousObject.ByPerson;
     Contact               = previousObject.Contact;
     ScheduleQuantity      = previousObject.ScheduleQuantity;
     ResourceQuantity      = previousObject.ResourceQuantity;
     ContactName           = previousObject.ContactName;
     ResourceHasFiles      = previousObject.ResourceHasFiles;
     Files                 = previousObject.Files;
 }
예제 #6
0
        public ScheduleEventModel(Schedule schedule)
        {
            ScheduleId              = schedule.Id;
            ResourceId              = schedule.Resource.Id;
            ResourceName            = schedule.Resource.Name;
            ResourceDescription     = schedule.Resource.Description;
            ResourceAttributeValues = schedule.Resource.ResourceAttributeValues;
            Files        = new List <FileValueModel>();
            WithActivity = schedule.Resource.WithActivity;

            //Get File to Resource if exsist
            foreach (ResourceAttributeUsage usage in schedule.Resource.ResourceStructure.ResourceAttributeUsages)
            {
                if (usage.IsFileDataType)
                {
                    using (ResourceStructureAttributeManager valueManager = new ResourceStructureAttributeManager())
                    {
                        ResourceAttributeValue value = valueManager.GetValueByUsageAndResource(usage.Id, schedule.Resource.Id);
                        if (value is FileValue)
                        {
                            FileValue      fileValue = (FileValue)value;
                            FileValueModel fvm       = new FileValueModel(fileValue);
                            Files.Add(fvm);
                            if (!usage.IsValueOptional)
                            {
                                ResourceHasFiles = true;
                            }
                        }
                    }
                }
            }

            ScheduleDurationModel scheduleDurationModel = new ScheduleDurationModel();

            scheduleDurationModel.StartDate     = schedule.StartDate;
            scheduleDurationModel.EndDate       = schedule.EndDate;
            scheduleDurationModel.DurationValue = schedule.Resource.Duration.Value;
            scheduleDurationModel.TimeUnit      = schedule.Resource.Duration.TimeUnit;

            ScheduleDurationModel = scheduleDurationModel;
            ScheduleQuantity      = schedule.Quantity;
            ResourceQuantity      = schedule.Resource.Quantity;
            Status = schedule.Resource.ResourceStatus.ToString();

            //get Persons
            ForPersons = new List <PersonInSchedule>();

            if (schedule.ForPerson.Self is PersonGroup)
            {
                PersonGroup pGroup = (PersonGroup)schedule.ForPerson.Self;

                Contact     = new PersonInSchedule(pGroup.Id, pGroup.Contact, true);
                ContactName = pGroup.Contact.DisplayName;

                foreach (User u in pGroup.Users)
                {
                    if (u.Id == pGroup.Contact.Id)
                    {
                        ForPersons.Add(new PersonInSchedule(pGroup.Id, u, true));
                    }
                    else
                    {
                        ForPersons.Add(new PersonInSchedule(pGroup.Id, u, false));
                    }
                }
            }
            else if (schedule.ForPerson.Self is IndividualPerson)
            {
                IndividualPerson iPerson = (IndividualPerson)schedule.ForPerson.Self;
                Contact     = new PersonInSchedule(iPerson.Id, iPerson.Contact, true);
                ContactName = iPerson.Contact.DisplayName;

                ForPersons.Add(new PersonInSchedule(iPerson.Id, iPerson.Person, true));
            }

            if (schedule.ByPerson.Self is IndividualPerson)
            {
                IndividualPerson iPersonBy = (IndividualPerson)schedule.ByPerson.Self;

                ByPerson = iPersonBy.Person.DisplayName;
            }
        }