Exemplo n.º 1
0
 public static void Initialize(CoordinatorPluginPhase pluginPhase, ContractorCoordinator coordinator, Contractor businessObject)
 {
     if (pluginPhase == CoordinatorPluginPhase.SaveObject && coordinator != null && businessObject.BOType == BusinessObjectType.ApplicationUser)
     {
         coordinator.Plugins.Add(new ApplicationUserPlugin());
     }
 }
Exemplo n.º 2
0
        private void LoadUserData(User user, XElement xml)
        {
            try
            {
                DictionaryMapper.Instance.DictionaryLock.EnterReadLock();
                Branch b = DictionaryMapper.Instance.GetFirstBranchByDatabaseId(ConfigurationMapper.Instance.DatabaseId);

                if (b == null)
                {
                    throw new InvalidOperationException("No branch for the current database id");
                }

                using (ContractorCoordinator cCoord = new ContractorCoordinator(false, false))
                {
                    user.UserName = cCoord.LoadBusinessObject <Contractor>(user.UserId).FullName;
                }

                user.BranchId          = b.Id.Value;
                user.CompanyId         = b.CompanyId;
                user.PermissionProfile = xml.Element("permissionProfile").Value;

                SessionManager.PaymentForDocumentLabel = ConfigurationMapper.Instance.GetConfiguration(user, "document.labels.paymentForDocument").First().Value.Value;
            }
            finally
            {
                DictionaryMapper.Instance.DictionaryLock.ExitReadLock();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the custom logic.
        /// </summary>
        /// <param name="document">The document to execute custom logic for.</param>
        private void ExecuteCustomLogic(ServiceDocument document)
        {
            //create new contractor and attach him to the document if its neccesary
            if (document.ReceivingPerson != null && document.ReceivingPerson.IsNew &&
                (document.ReceivingPerson != null && document.Contractor == null) == false)
            {
                using (ContractorCoordinator contractorCoordinator = new ContractorCoordinator(false, false))
                {
                    Contractor newContractor = (Contractor)contractorCoordinator.CreateNewBusinessObject(BusinessObjectType.Contractor, null, null);

                    newContractor.ShortName        = document.ReceivingPerson.ShortName;
                    newContractor.FullName         = document.ReceivingPerson.FullName;
                    newContractor.IsBusinessEntity = document.ReceivingPerson.IsBusinessEntity;
                    newContractor.Status           = BusinessObjectStatus.New;
                    document.ReceivingPerson       = newContractor;

                    //load full document contractor data (maybe its not necessary, but we dont know if we already have full info about contractor)
                    Contractor documentContractor = (Contractor)contractorCoordinator.LoadBusinessObject(document.Contractor.BOType,
                                                                                                         document.Contractor.Id.Value);
                    document.Contractor = documentContractor;
                }
            }

            this.ProcessServiceReservation(document);
            this.ProcessDocumentsGeneration(document);
        }
Exemplo n.º 4
0
        public static void Initialize(CoordinatorPluginPhase pluginPhase, ContractorCoordinator coordinator)
        {
            if (pluginPhase != CoordinatorPluginPhase.SaveObject)
            {
                return;
            }

            coordinator.Plugins.Add(new ContractorCodeExistenceCheckPlugin());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Executes the custom logic during transaction.
        /// </summary>
        /// <param name="document">The document to execute custom logic for.</param>
        private void ExecuteCustomLogicDuringTransaction(CommercialDocument document)
        {
            if (document.ReceivingPerson != null && document.ReceivingPerson.IsNew)
            {
                using (ContractorCoordinator contractorCoordinator = new ContractorCoordinator(false, false))
                {
                    Contractor documentContractor  = (Contractor)document.Contractor;
                    Contractor receivingContractor = (Contractor)document.ReceivingPerson;

                    ContractorRelation relation = documentContractor.Relations.CreateNew();
                    relation.ContractorRelationTypeName = ContractorRelationTypeName.Contractor_ContactPerson;
                    relation.RelatedObject = receivingContractor;

                    contractorCoordinator.SaveBusinessObject(documentContractor);

                    document.ReceivingPerson.Version = receivingContractor.NewVersion;
                }
            }
        }
Exemplo n.º 6
0
        private void ExecuteCustomLogic(CommercialDocument document)
        {
            //create new contractor and attach him to the document if its neccesary
            if (document.ReceivingPerson != null && document.ReceivingPerson.IsNew &&
                (document.ReceivingPerson != null && document.Contractor == null) == false)
            {
                using (ContractorCoordinator contractorCoordinator = new ContractorCoordinator(false, false))
                {
                    Contractor newContractor = (Contractor)contractorCoordinator.CreateNewBusinessObject(BusinessObjectType.Contractor, null, null);

                    newContractor.ShortName        = document.ReceivingPerson.ShortName;
                    newContractor.FullName         = document.ReceivingPerson.FullName;
                    newContractor.IsBusinessEntity = document.ReceivingPerson.IsBusinessEntity;
                    newContractor.Status           = BusinessObjectStatus.New;
                    document.ReceivingPerson       = newContractor;

                    //load full document contractor data (maybe its not necessary, but we dont know if we already have full info about contractor)
                    Contractor documentContractor = (Contractor)contractorCoordinator.LoadBusinessObject(document.Contractor.BOType,
                                                                                                         document.Contractor.Id.Value);
                    document.Contractor = documentContractor;
                }
            }

            this.mapper.AddItemsToItemTypesCache(document);
            IDictionary <Guid, Guid> cache = SessionManager.VolatileElements.ItemTypesCache;

            if (document.DocumentType.Options.Descendants("template").Attributes("LineAttribute_SalesOrderGenerateDocumentOption").Count() > 0)
            {
                foreach (var line in document.Lines)
                {
                    var attr = line.Attributes[DocumentFieldName.LineAttribute_SalesOrderGenerateDocumentOption];

                    if (attr == null)
                    {
                        throw new ClientException(ClientExceptionId.MissingLineAttribute, null, "ordinalNumber:" + line.OrdinalNumber.ToString(CultureInfo.InvariantCulture));
                    }

                    Guid     itemTypeId = cache[line.ItemId];
                    ItemType itemType   = DictionaryMapper.Instance.GetItemType(itemTypeId);

                    if (!itemType.IsWarehouseStorable)
                    {
                        continue;
                    }

                    string option = attr.Value.Value;

                    if (document.DocumentStatus != DocumentStatus.Canceled)
                    {
                        if (option == "3" || option == "4")
                        {
                            line.OrderDirection = -1;
                        }
                        else
                        {
                            line.OrderDirection = 0;
                        }
                    }
                    else
                    {
                        line.OrderDirection = 0;
                    }
                }
            }

            if (!document.IsNew)
            {
                CommercialDocument alternateDocument = (CommercialDocument)document.AlternateVersion;

                if (document.DocumentStatus == DocumentStatus.Committed && alternateDocument.DocumentStatus != DocumentStatus.Committed)
                {
                    var attr = document.Attributes.CreateNew(BusinessObjectStatus.New);
                    attr.DocumentFieldName = DocumentFieldName.Attribute_SettlementDate;
                    attr.Value.Value       = SessionManager.VolatileElements.CurrentDateTime.ToIsoString();
                }
            }
        }