Exemplo n.º 1
0
        public override Sungero.Docflow.IOfficialDocument ChangeDocumentType(List <Domain.Shared.IEntityInfo> types)
        {
            Sungero.Docflow.IOfficialDocument convertedDoc = null;

            // Запретить смену типа, если документ или его тело заблокировано.
            var isCalledByDocument = CallContext.CalledDirectlyFrom(Docflow.OfficialDocuments.Info);

            if (isCalledByDocument && Docflow.PublicFunctions.Module.IsLockedByOther(_obj) ||
                !isCalledByDocument && Docflow.PublicFunctions.Module.IsLocked(_obj) ||
                Docflow.PublicFunctions.Module.VersionIsLocked(_obj.Versions.ToList()))
            {
                Dialogs.ShowMessage(Docflow.ExchangeDocuments.Resources.ChangeDocumentTypeLockError,
                                    MessageType.Error);
                return(convertedDoc);
            }

            var contract = _obj.LeadingDocument;

            // Открыть диалог по смене типа.
            var title  = Docflow.ExchangeDocuments.Resources.TypeChange;
            var dialog = Dialogs.CreateSelectTypeDialog(title, types.ToArray());

            if (dialog.Show() == DialogButtons.Ok)
            {
                convertedDoc = Docflow.OfficialDocuments.As(_obj.ConvertTo(dialog.SelectedType));
            }

            // Котегов: Не работает маппинг, если свойства нет в документе-источнике (115833).
            Contracts.PublicFunctions.IncomingInvoice.FillContractFromLeadingDocument(convertedDoc, contract);

            return(convertedDoc);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Построить модель контрола состояния документа.
 /// </summary>
 /// <param name="document">Документ.</param>
 /// <returns>Модель контрола состояния.</returns>
 public Sungero.Core.StateView GetStateView(Sungero.Docflow.IOfficialDocument document)
 {
     if (_obj.AllAttachments.Any(d => Equals(document, d)))
     {
         return(this.GetStateView());
     }
     else
     {
         return(StateView.Create());
     }
 }
Exemplo n.º 3
0
        public static IOutgoingLetter CreateCoverLetter(Sungero.Docflow.IOfficialDocument document)
        {
            var letter = OutgoingLetters.Create();

            letter.Subject        = string.Format("{0}{1}", OutgoingLetters.Resources.Sending, document.Name);
            letter.BusinessUnit   = document.BusinessUnit;
            letter.DeliveryMethod = document.DeliveryMethod;
            Docflow.PublicFunctions.OfficialDocument.CopyProjects(document, letter);

            var contractualDocument = Sungero.Docflow.ContractualDocumentBases.As(document);

            if (contractualDocument != null)
            {
                letter.Correspondent = contractualDocument.Counterparty;
            }
            var financialDocument = Sungero.Docflow.AccountingDocumentBases.As(document);

            if (financialDocument != null)
            {
                letter.Correspondent = financialDocument.Counterparty;
            }

            return(letter);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Регистрация документа.
        /// </summary>
        /// <param name="session">Текущая сессия.</param>
        /// <param name="edoc">Экземпляр документа.</param>
        /// <param name="documentRegisterId">ИД журнала регистрации.</param>
        /// <param name="regNumber">Рег. №</param>
        /// <param name="regDate">Дата регистрации.</param>
        /// <param name="logger">Логировщик.</param>
        /// <returns>Список ошибок.</returns>
        public static IEnumerable <Structures.ExceptionsStruct> RegisterDocument(Session session, Sungero.Docflow.IOfficialDocument edoc, int documentRegisterId, string regNumber, DateTime?regDate, Guid defaultRegistrationRoleGuid, NLog.Logger logger)
        {
            var exceptionList = new List <Structures.ExceptionsStruct>();

            Sungero.Docflow.IRegistrationGroup regGroup = null;
            // TODO Кэшировать.
            var documentRegister = BusinessLogic.GetDocumentRegister(session, documentRegisterId);

            if (documentRegister != null && regDate != null && !string.IsNullOrEmpty(regNumber))
            {
                edoc.RegistrationDate   = regDate;
                edoc.RegistrationNumber = regNumber;
                edoc.DocumentRegister   = documentRegister;
                edoc.RegistrationState  = Sungero.Docflow.OfficialDocument.RegistrationState.Registered;
                regGroup = documentRegister.RegistrationGroup;
            }
            else
            {
                var message = string.Format("Не удалось найти соответствующий реестр с ИД \"{0}\".", documentRegisterId);
                exceptionList.Add(new Structures.ExceptionsStruct {
                    ErrorType = Constants.ErrorTypes.Warn, Message = message
                });
                logger.Warn(message);
            }

            if (regGroup != null)
            {
                edoc.AccessRights.Grant(regGroup, DefaultAccessRightsTypes.FullAccess);
            }
            else
            {
                var message = string.Format("Не была найдена соответствующая группа регистрации. Права на документ будут выданы для роли c Guid {0}.", defaultRegistrationRoleGuid.ToString());
                exceptionList.Add(new Structures.ExceptionsStruct {
                    ErrorType = Constants.ErrorTypes.Warn, Message = message
                });
                logger.Warn(message);
                var regRole = BusinessLogic.GetRoleBySid(session, defaultRegistrationRoleGuid);
                edoc.AccessRights.Grant(regRole, DefaultAccessRightsTypes.FullAccess);
            }
            try
            {
                edoc.Save();
            }
            catch (Exception ex)
            {
                exceptionList.Add(new Structures.ExceptionsStruct {
                    ErrorType = Constants.ErrorTypes.Warn, Message = ex.Message
                });
            }
            return(exceptionList);
        }