Exemplo n.º 1
0
        /// <summary>
        /// Forwards the communication package in headquarter branch.
        /// </summary>
        /// <param name="communicationPackage">The communication package.</param>
        /// <param name="repository">The communication package repository.</param>
        private void ForwardInHeadquarter(ICommunicationPackage communicationPackage, ICommunicationPackageRepository repository)
        {
            XDocument commPkg     = XDocument.Parse(communicationPackage.XmlData.Content);
            var       skipPackage = XDocument.Parse(communicationPackage.XmlData.Content).Root.Attribute("skipPackage");

            if (skipPackage != null && skipPackage.Value.Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            CommunicationPackageType pkgType = GetPackageType(communicationPackage);

            if (pkgType == CommunicationPackageType.Configuration ||
                pkgType == CommunicationPackageType.ContractorSnapshot ||
                pkgType == CommunicationPackageType.ContractorRelations ||
                pkgType == CommunicationPackageType.ContractorGroupMembership ||
                pkgType == CommunicationPackageType.ItemSnapshot ||
                pkgType == CommunicationPackageType.ItemRelation ||
                pkgType == CommunicationPackageType.ItemGroupMembership ||
                pkgType == CommunicationPackageType.ItemUnitRelation ||
                pkgType == CommunicationPackageType.WarehouseStock ||
                pkgType == CommunicationPackageType.Payment ||
                //pkgType == CommunicationPackageType.PaymentSettlementSnapshot ||
                pkgType == CommunicationPackageType.FileDescriptor ||
                pkgType == CommunicationPackageType.DictionaryPackage ||
                pkgType == CommunicationPackageType.PriceRule ||
                pkgType == CommunicationPackageType.PriceRuleList ||
                pkgType == CommunicationPackageType.Custom)
            {
                IEnumerable <Guid> destinationDatabases = GetDestinations(communicationPackage, repository.Context.ConnectionManager);
                if (destinationDatabases != null)
                {
                    repository.PutToOutgoingQueue(communicationPackage, destinationDatabases);
                }
            }
            else if (pkgType == CommunicationPackageType.WarehouseDocumentSnapshot)
            {
                if (commPkg.Root.Element("warehouseDocumentLine").Elements("entry").All(row => row.Element("isDistributed").Value.Equals("1")))
                {
                    ForwardShiftDocument(communicationPackage, repository, commPkg);
                }
            }
            else if (pkgType == CommunicationPackageType.WarehouseDocumentValuation)
            {
                // zapobiega zapetleniu paczek
                if (communicationPackage.DatabaseId != this.currentDatabaseId)
                {
                    ForwardValuations(communicationPackage, commPkg, repository);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the destinations departments for specified communication package.
        /// </summary>
        /// <param name="communicationPackage">The communication package.</param>
        /// <param name="dbMan">The database connection manager.</param>
        /// <returns>Collection of destination department ids.</returns>
        internal IEnumerable <Guid> GetDestinations(ICommunicationPackage communicationPackage, IDatabaseConnectionManager dbMan)
        {
            if (this.destinations == null)
            {
                Makolab.Fractus.Communication.DBLayer.CommunicationPackageMapper mapper =
                    new Makolab.Fractus.Communication.DBLayer.CommunicationPackageMapper(dbMan);

                destinations = mapper.GetDestinations();
            }
            CommunicationPackageType type = GetPackageType(communicationPackage);

            if (this.destinations.ContainsKey(type) == false)
            {
                return(null);
            }

            return((from branch in this.destinations[type]
                    where branch.DatabaseId != communicationPackage.DatabaseId.Value &&
                    branch.DatabaseId != currentDatabaseId.Value
                    select branch.DatabaseId).Distinct());
        }