示例#1
0
        /// <summary>
        /// Remove the <see cref="Organization"/>
        /// </summary>
        /// <param name="organizationalParticipant">
        /// the <see cref="OrganizationalParticipant"/> object to remove
        /// </param>
        private void RemoveOrganization(OrganizationalParticipant organizationalParticipant)
        {
            var row = this.organizationFolderRow.ContainedRows.SingleOrDefault(r => ((OrganizationalParticipationRowViewModel)r).OrganizationalParticipation.Equals(organizationalParticipant));

            if (row != null)
            {
                this.organizationFolderRow.ContainedRows.RemoveAndDispose(row);
            }
        }
        /// <summary>
        /// Serialize the <see cref="OrganizationalParticipant"/>
        /// </summary>
        /// <param name="organizationalParticipant">The <see cref="OrganizationalParticipant"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(OrganizationalParticipant organizationalParticipant)
        {
            var jsonObject = new JObject();

            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), organizationalParticipant.ClassKind)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](organizationalParticipant.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](organizationalParticipant.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](organizationalParticipant.Iid));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](organizationalParticipant.ModifiedOn));
            jsonObject.Add("organization", this.PropertySerializerMap["organization"](organizationalParticipant.Organization));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](organizationalParticipant.RevisionNumber));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](organizationalParticipant.ThingPreference));
            return(jsonObject);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IterationSetupRowViewModel" /> class
        /// </summary>
        /// <param name="organizationalParticipation">The <see cref="OrganizationalParticipant" /> this is associated to</param>
        /// <param name="session">The session</param>
        /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}" /></param>
        public OrganizationalParticipationRowViewModel(OrganizationalParticipant organizationalParticipation, ISession session, IViewModelBase <Thing> containerViewModel)
            : base(organizationalParticipation.Organization, session, containerViewModel)
        {
            this.OrganizationalParticipation = organizationalParticipation;

            var thingSubscription = CDPMessageBus.Current.Listen <ObjectChangedEvent>(this.OrganizationalParticipation)
                                    .Where(objectChange => objectChange.EventKind == EventKind.Updated && objectChange.ChangedThing.RevisionNumber > this.RevisionNumber)
                                    .ObserveOn(RxApp.MainThreadScheduler)
                                    .Subscribe(_ => this.UpdateProperties());

            this.Disposables.Add(thingSubscription);

            var containerSubscription = CDPMessageBus.Current.Listen <ObjectChangedEvent>(this.OrganizationalParticipation.Container)
                                        .Where(objectChange => objectChange.EventKind == EventKind.Updated && objectChange.ChangedThing.RevisionNumber > this.RevisionNumber)
                                        .ObserveOn(RxApp.MainThreadScheduler)
                                        .Subscribe(_ => this.UpdateProperties());

            this.Disposables.Add(containerSubscription);

            this.UpdateProperties();
        }
        /// <summary>
        /// Updates the <see cref="Transaction" /> with the changes recorded in the current view-model
        /// </summary>
        protected override void UpdateTransaction()
        {
            base.UpdateTransaction();

            var clone = this.Thing;

            clone.ActiveDomain.Clear();
            clone.ActiveDomain.AddRange(this.ActiveDomain.Select(ad => ad.DomainOfExpertise));

            // organizational prticipation
            if (this.SelectedOrganizations.Any() || this.Thing.OrganizationalParticipant.Any())
            {
                var existingOrganizations = this.Thing.OrganizationalParticipant.Select(op => op.Organization).ToList();

                var newOrgs     = this.SelectedOrganizations.Except(existingOrganizations);
                var deletedOrgs = existingOrganizations.Except(this.SelectedOrganizations);

                foreach (var organization in newOrgs)
                {
                    var orgParticipation = new OrganizationalParticipant
                    {
                        Organization = organization
                    };

                    this.Thing.OrganizationalParticipant.Add(orgParticipation);
                    this.transaction.Create(orgParticipation);
                }

                foreach (var organization in deletedOrgs)
                {
                    var participantion = this.Thing.OrganizationalParticipant.FirstOrDefault(p => p.Organization.Equals(organization))?.Clone(false);

                    if (participantion != null)
                    {
                        this.transaction.Delete(participantion, this.Thing);
                    }
                }
            }

            this.Thing.DefaultOrganizationalParticipant = this.Thing.OrganizationalParticipant.FirstOrDefault(p => p.Organization.Equals(this.SelectedDefaultOrganization));

            if (this.dialogKind.Equals(ThingDialogKind.Update))
            {
                return;
            }

            // set the source SourceEngineeringModelSetup if the model is derived, otherwise set the Required RDL
            if (this.SourceEngineeringModelSetup == null)
            {
                this.Thing.SourceEngineeringModelSetupIid = null;
                this.Thing.RequiredRdl.Clear();

                // this is a non-derived EMS thus a new engineering model rdl has to be passed in as well
                var mrdl = new ModelReferenceDataLibrary();
                mrdl.Name        = string.Concat(this.Name, " Model RDL");
                mrdl.ShortName   = string.Concat(this.ShortName, "MRDL");
                mrdl.RequiredRdl = this.SelectedSiteReferenceDataLibrary;
                this.Thing.RequiredRdl.Add(mrdl);
                this.transaction.Create(mrdl);
            }
            else
            {
                if (this.SourceEngineeringModelSetup != null)
                {
                    this.Thing.SourceEngineeringModelSetupIid = this.SourceEngineeringModelSetup.Iid;
                }
            }

            this.Thing.EngineeringModelIid = Guid.NewGuid();
        }
示例#5
0
        /// <summary>
        /// Add the <see cref="Organization"/>
        /// </summary>
        /// <param name="organizationalParticipation">
        /// the <see cref="OrganizationalParticipant"/> object to add
        /// </param>
        private void AddOrganization(OrganizationalParticipant organizationalParticipation)
        {
            var row = new OrganizationalParticipationRowViewModel(organizationalParticipation, this.Session, this);

            this.organizationFolderRow.ContainedRows.Add(row);
        }