Пример #1
0
        public static void BaseOnPostDerive(this WorkEffort @this, ObjectOnPostDerive method)
        {
            if ([email protected])
            {
                @this.AddDeniedPermission(new Permissions(@this.Strategy.Session).Get((Class)@this.Strategy.Class, MetaWorkEffort.Instance.Invoice, Operations.Execute));
            }
            else
            {
                @this.RemoveDeniedPermission(new Permissions(@this.Strategy.Session).Get((Class)@this.Strategy.Class, MetaWorkEffort.Instance.Invoice, Operations.Execute));
            }

            var completePermission = new Permissions(@this.Strategy.Session).Get((Class)@this.Strategy.Class, MetaWorkEffort.Instance.Complete, Operations.Execute);

            if (@this.ServiceEntriesWhereWorkEffort.Any(v => !v.ExistThroughDate))
            {
                @this.AddDeniedPermission(new Permissions(@this.Strategy.Session).Get((Class)@this.Strategy.Class, MetaWorkEffort.Instance.Complete, Operations.Execute));
            }
            else
            {
                if (@this.WorkEffortState.IsInProgress)
                {
                    @this.RemoveDeniedPermission(new Permissions(@this.Strategy.Session).Get((Class)@this.Strategy.Class, MetaWorkEffort.Instance.Complete, Operations.Execute));
                }
            }

            if (@this.WorkEffortState.IsFinished)
            {
                if (@this.ExecutedBy.Equals(@this.Customer))
                {
                    @this.RemoveDeniedPermission(new Permissions(@this.Strategy.Session).Get((Class)@this.Strategy.Class, MetaWorkEffort.Instance.Revise, Operations.Execute));
                }
            }
        }
Пример #2
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var builder = new StringBuilder();

            if (this.ExistProductIdentifications)
            {
                builder.Append(string.Join(" ", this.ProductIdentifications.Select(v => v.Identification)));
            }

            if (this.ExistProductCategoriesWhereAllProduct)
            {
                builder.Append(string.Join(" ", this.ProductCategoriesWhereAllProduct.Select(v => v.Name)));
            }

            builder.Append(string.Join(" ", this.Keywords));

            this.SearchString = builder.ToString();

            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }
        }
Пример #3
0
 public void AppsOnPostDerive(ObjectOnPostDerive method)
 {
     if (!this.ExistOriginator)
     {
         this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Submit, Operations.Execute));
     }
 }
Пример #4
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }

            if (!this.PurchaseOrderItemShipmentState.IsNotReceived)
            {
                var deniablePermissionByOperandTypeId = new Dictionary <Guid, Permission>();

                foreach (Permission permission in this.Session().Extent <Permission>())
                {
                    if (permission.ConcreteClassPointer == this.strategy.Class.Id &&
                        (permission.Operation == Operations.Write || permission.Operation == Operations.Execute))
                    {
                        deniablePermissionByOperandTypeId.Add(permission.OperandTypePointer, permission);
                    }
                }

                foreach (var keyValuePair in deniablePermissionByOperandTypeId)
                {
                    this.AddDeniedPermission(keyValuePair.Value);
                }
            }
        }
Пример #5
0
        public static void CoreOnPostDerive(this Transitional @this, ObjectOnPostDerive method)
        {
            // Update PreviousObjectState and LastObjectState
            foreach (var transitionalConfiguration in @this.TransitionalConfigurations)
            {
                var objectState     = @this.Strategy.GetCompositeRole(transitionalConfiguration.ObjectState);
                var lastObjectState = @this.Strategy.GetCompositeRole(transitionalConfiguration.LastObjectState);

                if (objectState != null && !objectState.Equals(lastObjectState))
                {
                    @this.Strategy.SetCompositeRole(transitionalConfiguration.PreviousObjectState, lastObjectState);
                }

                @this.Strategy.SetCompositeRole(transitionalConfiguration.LastObjectState, objectState);
            }

            // Rollup ObjectStates, PreviousObjectState and LastObjectStates
            @this.DerivedRoles.RemoveObjectStates();
            @this.DerivedRoles.RemoveLastObjectStates();
            @this.DerivedRoles.RemovePreviousObjectStates();
            foreach (var transitionalConfiguration in @this.TransitionalConfigurations)
            {
                var objectState         = (ObjectState)@this.Strategy.GetCompositeRole(transitionalConfiguration.ObjectState);
                var lastObjectState     = (ObjectState)@this.Strategy.GetCompositeRole(transitionalConfiguration.LastObjectState);
                var previousObjectState = (ObjectState)@this.Strategy.GetCompositeRole(transitionalConfiguration.PreviousObjectState);
                @this.DerivedRoles.AddObjectState(objectState);
                @this.DerivedRoles.AddLastObjectState(lastObjectState);
                @this.DerivedRoles.AddPreviousObjectState(previousObjectState);
            }

            // Update security
            @this.DeniedPermissions = @this.ObjectStates.SelectMany(v => v.DeniedPermissions).ToArray();
        }
Пример #6
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var SetReadyPermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.SetReadyForProcessing, Operations.Execute);

            if (this.QuoteState.IsCreated)
            {
                if (this.ExistValidQuoteItems)
                {
                    this.RemoveDeniedPermission(SetReadyPermission);
                }
                else
                {
                    this.AddDeniedPermission(SetReadyPermission);
                }
            }

            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }
        }
Пример #7
0
 public void AppsOnPostDerive(ObjectOnPostDerive method)
 {
     if (this.ExistSalesInvoiceWherePurchaseInvoice)
     {
         this.AddDeniedPermission(new Permissions(this.strategy.Session).Get(this.Meta.Class, this.Meta.CreateSalesInvoice, Operations.Execute));
     }
 }
Пример #8
0
        public static void BaseOnPostDerive(this CommunicationEvent @this, ObjectOnPostDerive method)
        {
            var session = @this.Strategy.Session;

            @this.AddSecurityToken(new SecurityTokens(session).DefaultSecurityToken);
            @this.AddSecurityToken(@this.Owner?.OwnerSecurityToken);
        }
Пример #9
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }

            var revisePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Revise, Operations.Execute);

            if (this.BilledTo.DoAccounting)
            {
                this.AddDeniedPermission(revisePermission);
            }

            if (!this.ExistSalesInvoiceWherePurchaseInvoice &&
                (this.BilledFrom as Organisation)?.IsInternalOrganisation == true &&
                (this.PurchaseInvoiceState.IsPaid || this.PurchaseInvoiceState.IsPartiallyPaid || this.PurchaseInvoiceState.IsNotPaid))
            {
                this.RemoveDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.CreateSalesInvoice, Operations.Execute));
            }
            else
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.CreateSalesInvoice, Operations.Execute));
            }
        }
Пример #10
0
        public static void BaseOnPostDerive(this Part @this, ObjectOnPostDerive method)
        {
            var builder = new StringBuilder();

            builder.Append(@this.Name);

            foreach (LocalisedText localisedText in @this.LocalisedNames)
            {
                builder.Append(string.Join(", ", localisedText.Text));
            }

            if (@this.ExistProductIdentifications)
            {
                builder.Append(string.Join(", ", @this.ProductIdentifications.Select(v => v.Identification)));
            }

            if (@this.ExistProductCategoriesWhereAllPart)
            {
                builder.Append(string.Join(", ", @this.ProductCategoriesWhereAllPart.Select(v => v.Name)));
            }

            if (@this.ExistSupplierOfferingsWherePart)
            {
                builder.Append(string.Join(", ", @this.SupplierOfferingsWherePart.Select(v => v.Supplier.PartyName)));
                builder.Append(string.Join(", ", @this.SupplierOfferingsWherePart.Select(v => v.SupplierProductId)));
                builder.Append(string.Join(", ", @this.SupplierOfferingsWherePart.Select(v => v.SupplierProductName)));
            }

            if (@this.ExistSerialisedItems)
            {
                builder.Append(string.Join(", ", @this.SerialisedItems.Select(v => v.SerialNumber)));
            }

            if (@this.ExistProductType)
            {
                builder.Append(string.Join(", ", @this.ProductType.Name));
            }

            if (@this.ExistBrand)
            {
                builder.Append(string.Join(", ", @this.Brand.Name));
            }

            if (@this.ExistModel)
            {
                builder.Append(string.Join(", ", @this.Model.Name));
            }

            foreach (PartCategory partCategory in @this.PartCategoriesWherePart)
            {
                builder.Append(string.Join(", ", partCategory.Name));
            }

            builder.Append(string.Join(", ", @this.Keywords));

            @this.SearchString = builder.ToString();
        }
Пример #11
0
 public static void AppsOnPostDerive(this WorkEffort @this, ObjectOnPostDerive method)
 {
     if ([email protected])
     {
         @this.AddDeniedPermission(new Permissions(@this.Strategy.Session).Get(@this.Strategy.Class, MetaWorkEffort.Instance.Invoice, Operations.Execute));
     }
     else
     {
         @this.RemoveDeniedPermission(new Permissions(@this.Strategy.Session).Get(@this.Strategy.Class, MetaWorkEffort.Instance.Invoice, Operations.Execute));
     }
 }
        public static void BaseOnPostDerive(this InventoryItem @this, ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;
            var part       = @this.Part;

            var builder = new StringBuilder();

            builder.Append(part.SearchString);

            @this.SearchString = builder.ToString();
        }
Пример #13
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }
        }
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;

            if (this.ExistPreviousQuantityOnHand && this.QuantityOnHand > this.PreviousQuantityOnHand)
            {
                this.BaseReplenishSalesOrders(derivation);
            }

            if (this.ExistPreviousQuantityOnHand && this.QuantityOnHand < this.PreviousQuantityOnHand)
            {
                this.BaseDepleteSalesOrders(derivation);
            }

            this.PreviousQuantityOnHand = this.QuantityOnHand;
        }
Пример #15
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            if (!this.ExistOriginator)
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Submit, Operations.Execute));
            }

            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);
            if (this.IsDeletable())
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }
        }
Пример #16
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;

            this.PreviousReservedFromNonSerialisedInventoryItem = this.ReservedFromNonSerialisedInventoryItem;
            this.PreviousQuantity = this.QuantityOrdered;
            this.PreviousProduct  = this.Product;

            if (this.ExistReservedFromNonSerialisedInventoryItem)
            {
                if (!this.ReservedFromNonSerialisedInventoryItem.Equals(this.PreviousReservedFromNonSerialisedInventoryItem))
                {
                    derivation.Mark(this.PreviousReservedFromNonSerialisedInventoryItem);
                }
            }

            if (!this.SalesOrderItemInvoiceState.NotInvoiced || !this.SalesOrderItemShipmentState.NotShipped)
            {
                var deniablePermissionByOperandTypeId = new Dictionary <Guid, Permission>();

                foreach (Permission permission in this.Session().Extent <Permission>())
                {
                    if (permission.ConcreteClassPointer == this.strategy.Class.Id &&
                        (permission.Operation == Operations.Write || permission.Operation == Operations.Execute))
                    {
                        deniablePermissionByOperandTypeId.Add(permission.OperandTypePointer, permission);
                    }
                }

                foreach (var keyValuePair in deniablePermissionByOperandTypeId)
                {
                    this.AddDeniedPermission(keyValuePair.Value);
                }
            }

            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }
        }
Пример #17
0
        public void AppsOnPostDerive(ObjectOnPostDerive method)
        {
            if (!this.CanShip)
            {
                this.AddDeniedPermission(new Permissions(this.strategy.Session).Get(this.Meta.Class, this.Meta.Ship, Operations.Execute));
            }

            if (!this.CanInvoice)
            {
                this.AddDeniedPermission(new Permissions(this.strategy.Session).Get(this.Meta.Class, this.Meta.Invoice, Operations.Execute));
            }

            if (this.SalesOrderState.Equals(new SalesOrderStates(this.Strategy.Session).InProcess) &&
                Equals(this.Store.BillingProcess, new BillingProcesses(this.strategy.Session).BillingForShipmentItems))
            {
                this.RemoveDeniedPermission(new Permissions(this.strategy.Session).Get(this.Meta.Class, this.Meta.Invoice, Operations.Execute));
            }
        }
Пример #18
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }

            var builder = new StringBuilder();

            builder.Append(this.ItemNumber);
            builder.Append(string.Join(" ", this.SerialNumber));
            builder.Append(string.Join(" ", this.Name));

            if (this.ExistOwnedBy)
            {
                builder.Append(string.Join(" ", this.OwnedBy.PartyName));
            }

            if (this.ExistBuyer)
            {
                builder.Append(string.Join(" ", this.Buyer.PartyName));
            }

            if (this.ExistSeller)
            {
                builder.Append(string.Join(" ", this.Seller.PartyName));
            }

            if (this.ExistPartWhereSerialisedItem)
            {
                builder.Append(string.Join(" ", this.PartWhereSerialisedItem?.Brand?.Name));
                builder.Append(string.Join(" ", this.PartWhereSerialisedItem?.Model?.Name));
            }

            builder.Append(string.Join(" ", this.Keywords));

            this.SearchString = builder.ToString();
        }
Пример #19
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;

            if (!this.ExistUnitPrice)
            {
                derivation.Validation.AddError(this, this.Meta.UnitPrice, ErrorMessages.UnitPriceRequired);
            }

            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }
        }
Пример #20
0
        public void AppsOnPostDerive(ObjectOnPostDerive method)
        {
            this.RemoveSecurityTokens();
            this.AddSecurityToken(Singleton.Instance(this.Strategy.Session).DefaultSecurityToken);

            if (this.ExistOwner)
            {
                this.AddSecurityToken(this.Owner.OwnerSecurityToken);
            }

            foreach (Party participant in this.Participants)
            {
                if (participant.GetType().Name == PersonClass.Instance.Name)
                {
                    var person = participant as Person;
                    if (person.ExistCurrentEmployment)
                    {
                        this.AddSecurityToken(person.CurrentEmployment.Employer.OwnerSecurityToken);
                    }

                    if (person.ExistOrganisationContactRelationshipsWhereContact)
                    {
                        foreach (
                            OrganisationContactRelationship organisationContactRelationship in
                                person.OrganisationContactRelationshipsWhereContact)
                        {
                            if (organisationContactRelationship.ExistOrganisation)
                            {
                                foreach (
                                    CustomerRelationship customerRelationship in
                                        organisationContactRelationship.Organisation.CustomerRelationshipsWhereCustomer)
                                {
                                    this.AddSecurityToken(customerRelationship.InternalOrganisation.OwnerSecurityToken);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #21
0
        public static void BaseOnPostDerive(this Object @this, ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;
            var @class = (Class)@this.Strategy.Class;

            // Required
            RoleType[] requiredRoleTypes;
            if (!RequiredRoleTypesByClassName.TryGetValue(@class.Name, out requiredRoleTypes))
            {
                requiredRoleTypes = @class.ConcreteRoleTypes
                    .Where(concreteRoleType => concreteRoleType.IsRequired)
                    .Select(concreteRoleType => concreteRoleType.RoleType)
                    .ToArray();

                RequiredRoleTypesByClassName[@class.Name] = requiredRoleTypes;
            }

            foreach (var roleType in requiredRoleTypes)
            {
                derivation.Log.AssertExists(@this, roleType);
            }

            // Unique
            RoleType[] uniqueRoleTypes;
            if (!UniqueRoleTypesByClassName.TryGetValue(@class.Name, out uniqueRoleTypes))
            {
                uniqueRoleTypes = @class.ConcreteRoleTypes
                    .Where(concreteRoleType => concreteRoleType.IsUnique)
                    .Select(concreteRoleType => concreteRoleType.RoleType)
                    .ToArray();

                UniqueRoleTypesByClassName[@class.Name] = uniqueRoleTypes;
            }

            foreach (var roleType in uniqueRoleTypes)
            {
                derivation.Log.AssertIsUnique(@this, roleType);
            }
        }
Пример #22
0
        public static void BaseOnPostDerive(this Object @this, ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;
            var @class     = (Class)@this.Strategy.Class;

            // Required
            RoleType[] requiredRoleTypes;
            if (!RequiredRoleTypesByClassName.TryGetValue(@class.Name, out requiredRoleTypes))
            {
                requiredRoleTypes = @class.ConcreteRoleTypes
                                    .Where(concreteRoleType => concreteRoleType.IsRequired)
                                    .Select(concreteRoleType => concreteRoleType.RoleType)
                                    .ToArray();

                RequiredRoleTypesByClassName[@class.Name] = requiredRoleTypes;
            }

            foreach (var roleType in requiredRoleTypes)
            {
                derivation.Validation.AssertExists(@this, roleType);
            }

            // Unique
            RoleType[] uniqueRoleTypes;
            if (!UniqueRoleTypesByClassName.TryGetValue(@class.Name, out uniqueRoleTypes))
            {
                uniqueRoleTypes = @class.ConcreteRoleTypes
                                  .Where(concreteRoleType => concreteRoleType.IsUnique)
                                  .Select(concreteRoleType => concreteRoleType.RoleType)
                                  .ToArray();

                UniqueRoleTypesByClassName[@class.Name] = uniqueRoleTypes;
            }

            foreach (var roleType in uniqueRoleTypes)
            {
                derivation.Validation.AssertIsUnique(@this, roleType);
            }
        }
Пример #23
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }

            var builder = new StringBuilder();

            if (this.ExistProductIdentifications)
            {
                builder.Append(string.Join(" ", this.ProductIdentifications.Select(v => v.Identification)));
            }

            if (this.ExistProductCategoriesWhereAllProduct)
            {
                builder.Append(string.Join(" ", this.ProductCategoriesWhereAllProduct.Select(v => v.Name)));
            }

            if (this.ExistProductCategoriesWhereAllPart)
            {
                builder.Append(string.Join(" ", this.ProductCategoriesWhereAllPart.Select(v => v.Name)));
            }

            if (this.ExistSupplierOfferingsWherePart)
            {
                builder.Append(string.Join(" ", this.SupplierOfferingsWherePart.Select(v => v.Supplier.PartyName)));
            }

            if (this.ExistSerialisedItems)
            {
                builder.Append(string.Join(" ", this.SerialisedItems.Select(v => v.SerialNumber)));
                builder.Append(string.Join(" ", this.SerialisedItems.Select(v => v.ItemNumber)));
            }

            if (this.ExistProductType)
            {
                builder.Append(string.Join(" ", this.ProductType.Name));
            }

            if (this.ExistBrand)
            {
                builder.Append(string.Join(" ", this.Brand.Name));
            }

            if (this.ExistModel)
            {
                builder.Append(string.Join(" ", this.Model.Name));
            }

            foreach (PartCategory partCategory in this.PartCategoriesWherePart)
            {
                builder.Append(string.Join(" ", partCategory.Name));
            }

            builder.Append(string.Join(" ", this.Keywords));

            this.SearchString = builder.ToString();
        }
Пример #24
0
        public void AppsOnPostDerive(ObjectOnPostDerive method)
        {
            this.RemoveSecurityTokens();
            this.AddSecurityToken(Singleton.Instance(this.Strategy.Session).DefaultSecurityToken);

            if (this.ExistTakenByInternalOrganisation)
            {
                var securityToken = this.TakenByInternalOrganisation.OwnerSecurityToken;

                if (!this.SecurityTokens.Contains(securityToken))
                {
                    this.AddSecurityToken(securityToken);
                }
            }

            if (this.ExistBillToCustomer && !this.SecurityTokens.Contains(this.BillToCustomer.OwnerSecurityToken))
            {
                this.AddSecurityToken(this.BillToCustomer.OwnerSecurityToken);
            }

            if (this.ExistPreviousBillToCustomer && !this.BillToCustomer.Equals(this.PreviousBillToCustomer))
            {
                this.RemoveSecurityToken(this.PreviousBillToCustomer.OwnerSecurityToken);
            }

            if (this.ExistShipToCustomer && !this.SecurityTokens.Contains(this.ShipToCustomer.OwnerSecurityToken))
            {
                this.AddSecurityToken(this.ShipToCustomer.OwnerSecurityToken);
            }

            if (this.ExistPreviousShipToCustomer && !this.ShipToCustomer.Equals(this.PreviousShipToCustomer))
            {
                this.RemoveSecurityToken(this.PreviousShipToCustomer.OwnerSecurityToken);
            }
        }
Пример #25
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;

            this.PreviousSecondaryParents = this.SecondaryParents;
        }
Пример #26
0
        public static void CoreOnPostDerive(this Versioned @this, ObjectOnPostDerive method)
        {
            // TODO: move parts to Meta
            var derivation       = method.Derivation;
            var versionedClass   = (Class)@this.Strategy.Class;
            var metaPopulation   = versionedClass.MetaPopulation;
            var versionClass     = metaPopulation.FindByName(versionedClass.Name + "Version");
            var versionTypeRegex = new Regex(".+Version");

            var currentVersionRole = versionedClass.RoleTypes.First(v => v.Name.Equals("CurrentVersion"));
            var currentVersion     = @this.Strategy.GetCompositeRole(currentVersionRole.RelationType);

            var isNewVersion = currentVersion == null;

            if (!isNewVersion)
            {
                foreach (var versionRoleType in versionClass.RoleTypes.Where(v => versionTypeRegex.IsMatch(v.AssociationType.ObjectType.Name)))
                {
                    var versionedRoleType = versionedClass.RoleTypes.FirstOrDefault(v => v.Name.Equals(versionRoleType.Name));
                    if (versionedRoleType == null)
                    {
                        throw new Exception("Could not find versioned role " + versionRoleType.Name);
                    }

                    if (versionRoleType.IsMany)
                    {
                        var versionedRole = @this.Strategy.GetCompositeRoles(versionedRoleType.RelationType);
                        var versionRole   = currentVersion.Strategy.GetCompositeRoles(versionRoleType.RelationType);
                        if (!(versionedRole.Count == 0 && versionRole.Count == 0) ||
                            versionedRole.Count != versionRole.Count ||
                            !versionedRole.ToArray().OrderBy(s => s)
                            .SequenceEqual(versionRole.ToArray().OrderBy(t => t)))
                        {
                            isNewVersion = true;
                            break;
                        }
                    }
                    else
                    {
                        var versionedRole = @this.Strategy.GetRole(versionedRoleType.RelationType);
                        var versionRole   = currentVersion.Strategy.GetRole(versionRoleType.RelationType);
                        if (!object.Equals(versionedRole, versionRole))
                        {
                            isNewVersion = true;
                            break;
                        }
                    }
                }
            }

            if (isNewVersion)
            {
                var session    = @this.Strategy.Session;
                var newVersion = (Version)Allors.ObjectBuilder.Build(session, versionClass);
                newVersion.DerivationId        = derivation.Id;
                newVersion.DerivationTimeStamp = derivation.TimeStamp;

                foreach (var versionRoleType in versionClass.RoleTypes.Where(v => versionTypeRegex.IsMatch(v.AssociationType.ObjectType.Name)))
                {
                    var versionedRoleType = versionedClass.RoleTypes.FirstOrDefault(v => v.Name.Equals(versionRoleType.Name));
                    if (versionedRoleType == null)
                    {
                        throw new Exception("Could not find versioned role " + versionRoleType.Name + " on type " + versionedClass.Name);
                    }

                    var versionedRole = @this.Strategy.GetRole(versionedRoleType.RelationType);
                    newVersion.Strategy.SetRole(versionRoleType.RelationType, versionedRole);
                }

                var allVersionsRole = versionedClass.RoleTypes.First(v => v.Name.Equals("AllVersions"));

                @this.Strategy.SetRole(currentVersionRole.RelationType, newVersion);
                @this.Strategy.AddCompositeRole(allVersionsRole.RelationType, newVersion);
            }
        }
Пример #27
0
        public void AppsOnPostDerive(ObjectOnPostDerive method)
        {
            this.RemoveSecurityTokens();
            this.AddSecurityToken(this.OwnerSecurityToken);
            this.AddSecurityToken(Singleton.Instance(this.Strategy.Session).DefaultSecurityToken);

            foreach (Organisation organisation in this.PartiesWhereCurrentContact)
            {
                this.AddSecurityToken(organisation.OwnerSecurityToken);
            }

            if (this.ExistCurrentEmployment)
            {
                this.AddSecurityToken(this.CurrentEmployment.Employer.OwnerSecurityToken);
            }

            if (this.ExistOrganisationContactRelationshipsWhereContact)
            {
                foreach (OrganisationContactRelationship organisationContactRelationship in OrganisationContactRelationshipsWhereContact)
                {
                    if (organisationContactRelationship.ExistOrganisation)
                    {
                        foreach (CustomerRelationship customerRelationship in organisationContactRelationship.Organisation.CustomerRelationshipsWhereCustomer)
                        {
                            this.AddSecurityToken(customerRelationship.InternalOrganisation.OwnerSecurityToken);
                        }
                    }
                }
            }

            foreach (CustomerRelationship customerRelationship in this.CustomerRelationshipsWhereCustomer)
            {
                this.AddSecurityToken(customerRelationship.InternalOrganisation.OwnerSecurityToken);
            }
        }
Пример #28
0
 public void BaseOnPostDerive(ObjectOnPostDerive method)
 {
     this.CacheId = Guid.NewGuid();
 }
Пример #29
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;

            if (this.CanShip)
            {
                this.RemoveDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Ship, Operations.Execute));
            }
            else
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Ship, Operations.Execute));
            }

            if (this.CanInvoice)
            {
                this.RemoveDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Invoice, Operations.Execute));
            }
            else
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Invoice, Operations.Execute));
            }

            if (!this.SalesOrderInvoiceState.NotInvoiced || !this.SalesOrderShipmentState.NotShipped)
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.SetReadyForPosting, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Post, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Reopen, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Approve, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Hold, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Continue, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Accept, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Revise, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Complete, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Reject, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Cancel, Operations.Execute));

                var deniablePermissionByOperandTypeId = new Dictionary <Guid, Permission>();

                foreach (Permission permission in this.Session().Extent <Permission>())
                {
                    if (permission.ConcreteClassPointer == this.strategy.Class.Id && permission.Operation == Operations.Write)
                    {
                        deniablePermissionByOperandTypeId.Add(permission.OperandTypePointer, permission);
                    }
                }

                foreach (var keyValuePair in deniablePermissionByOperandTypeId)
                {
                    this.AddDeniedPermission(keyValuePair.Value);
                }
            }

            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }

            if (this.HasChangedStates())
            {
                derivation.Mark(this);
            }
        }
Пример #30
0
        public void AppsOnPostDerive(ObjectOnPostDerive method)
        {
            this.RemoveSecurityTokens();
            this.AddSecurityToken(this.OwnerSecurityToken);
            this.AddSecurityToken(Singleton.Instance(this.Strategy.Session).DefaultSecurityToken);

            foreach (CustomerRelationship customerRelationship in this.CustomerRelationshipsWhereCustomer)
            {
                this.AddSecurityToken(customerRelationship.InternalOrganisation.OwnerSecurityToken);
            }
        }
Пример #31
0
        public void BaseOnPostDerive(ObjectOnPostDerive method)
        {
            if (this.CanInvoice)
            {
                this.RemoveDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Invoice, Operations.Execute));
            }
            else
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Invoice, Operations.Execute));
            }

            if (this.CanRevise)
            {
                this.RemoveDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Revise, Operations.Execute));
            }
            else
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Revise, Operations.Execute));
            }

            if (this.IsReceivable)
            {
                this.RemoveDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.QuickReceive, Operations.Execute));
            }
            else
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.QuickReceive, Operations.Execute));
            }

            var deletePermission = new Permissions(this.Strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }

            if (!this.PurchaseOrderShipmentState.IsNotReceived && !this.PurchaseOrderShipmentState.IsNa)
            {
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Reject, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Cancel, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.QuickReceive, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Revise, Operations.Execute));
                this.AddDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.SetReadyForProcessing, Operations.Execute));

                var deniablePermissionByOperandTypeId = new Dictionary <Guid, Permission>();

                foreach (Permission permission in this.Session().Extent <Permission>())
                {
                    if (permission.ConcreteClassPointer == this.strategy.Class.Id && permission.Operation == Operations.Write)
                    {
                        deniablePermissionByOperandTypeId.Add(permission.OperandTypePointer, permission);
                    }
                }

                foreach (var keyValuePair in deniablePermissionByOperandTypeId)
                {
                    this.AddDeniedPermission(keyValuePair.Value);
                }
            }

            if (this.PurchaseOrderState.IsCompleted && this.PurchaseOrderPaymentState.IsNotPaid && this.PurchaseOrderShipmentState.IsNa)
            {
                this.RemoveDeniedPermission(new Permissions(this.Strategy.Session).Get(this.Meta.Class, this.Meta.Reopen, Operations.Execute));
            }
        }
Пример #32
0
        public static void BaseOnPostDerive(this Party @this, ObjectOnPostDerive method)
        {
            var derivation = method.Derivation;

            @this.BaseOnDerivePartyFinancialRelationships(derivation);
        }
Пример #33
0
        public void AppsOnPostDerive(ObjectOnPostDerive method)
        {
            this.RemoveSecurityTokens();
            this.AddSecurityToken(Allors.Domain.Singleton.Instance(this.Strategy.Session).DefaultSecurityToken);

            if (this.ExistShipToParty)
            {
                this.AddSecurityToken(this.ShipToParty.OwnerSecurityToken);
            }

            if (this.ExistStore && this.Store.ExistOwner)
            {
                if (this.Store.Owner.ExistOwnerSecurityToken && !this.SecurityTokens.Contains(this.Store.Owner.OwnerSecurityToken))
                {
                    this.AddSecurityToken(Store.Owner.OwnerSecurityToken);
                }
            }
        }
Пример #34
0
        public void AppsOnPostDerive(ObjectOnPostDerive method)
        {
            this.RemoveSecurityTokens();
            this.AddSecurityToken(Domain.Singleton.Instance(this.Strategy.Session).DefaultSecurityToken);

            if (this.ExistShipToParty)
            {
                this.AddSecurityToken(this.ShipToParty.OwnerSecurityToken);
            }
        }
Пример #35
0
 public static void AppsOnPostDerive(this CommunicationEvent @this, ObjectOnPostDerive method)
 {
     @this.AddSecurityToken(@this.Strategy.Session.GetSingleton().DefaultSecurityToken);
     @this.AddSecurityToken(@this.Owner?.OwnerSecurityToken);
 }
Пример #36
0
 public void BaseOnPostDerive(ObjectOnPostDerive method)
 {
     this.Type = this.MediaContent?.Type;
 }