Example #1
0
 public static IOfficialDocument Contract(IOutgoingDocumentBase document)
 {
   // Вернуть договор, если он был связан с исходящим письмом.
   var contractTypeGuid = Guid.Parse("f37c7e63-b134-4446-9b5b-f8811f6c9666");
   var contracts = document.Relations.GetRelatedFrom(Constants.Module.CorrespondenceRelationName).Where(d => d.TypeDiscriminator == contractTypeGuid);
   return Sungero.Docflow.OfficialDocuments.As(contracts.FirstOrDefault());
 }
Example #2
0
    public static string GetAddressees(IOutgoingDocumentBase document)
    {
      var result = string.Empty;
      if (document.Addressees.Count() > 4)
        result = OutgoingDocumentBases.Resources.ToManyAddressees;
      else
      {
        foreach (var addresse in document.Addressees.OrderBy(a => a.Number))
        {
          var person = Sungero.Parties.People.As(addresse.Correspondent);
          // Не выводить должность для персоны.
          if (person == null)
          {
            // Должность адресата в дательном падеже.
            var jobTitle = string.Format("<{0}>", OutgoingDocumentBases.Resources.JobTitle);
            if (addresse.Addressee != null && !string.IsNullOrEmpty(addresse.Addressee.JobTitle))
              jobTitle = CaseConverter.ConvertJobTitleToTargetDeclension(addresse.Addressee.JobTitle, Sungero.Core.DeclensionCase.Dative);

            result += jobTitle;
            result += Environment.NewLine;
          }
          
          // Организация адресата/ФИО Персоны.
          if (person == null)
            result += addresse.Correspondent.Name;
          else
          {
            var personName = CommonLibrary.PersonFullName.Create(person.LastName, person.FirstName, person.MiddleName, CommonLibrary.PersonFullNameDisplayFormat.LastNameAndInitials);
            result += CaseConverter.ConvertPersonFullNameToTargetDeclension(personName, Sungero.Core.DeclensionCase.Dative);
          }
          
          result += Environment.NewLine;
          
          // Не выводить ФИО адресата для персоны.
          if (person == null)
          {
            var addresseName = string.Format("<{0}>", OutgoingDocumentBases.Resources.InitialsAndLastName);
            // И.О. Фамилия адресата в дательном падеже.
            if (addresse.Addressee != null)
            {
              addresseName = addresse.Addressee.Name;
              if (addresse.Addressee.Person != null)
              {
                var personFullName = CommonLibrary.PersonFullName.Create(addresse.Addressee.Person.LastName,
                                                                         addresse.Addressee.Person.FirstName,
                                                                         addresse.Addressee.Person.MiddleName,
                                                                         CommonLibrary.PersonFullNameDisplayFormat.InitialsAndLastName);
                addresseName = CaseConverter.ConvertPersonFullNameToTargetDeclension(personFullName, Sungero.Core.DeclensionCase.Dative);
              }
            }
            result += addresseName;
            result += Environment.NewLine;
          }
          
          // Адрес доставки.
          var postalAddress = string.Format("<{0}>", OutgoingDocumentBases.Resources.PostalAddress);
          if (!string.IsNullOrEmpty(addresse.Correspondent.PostalAddress))
            postalAddress = addresse.Correspondent.PostalAddress;
          result += postalAddress;
          result += Environment.NewLine;
          result += Environment.NewLine;
        }
      }
      return result.Trim();
    }
        public static string GetContactsInformation(Docflow.IOutgoingDocumentBaseAddressees addresseesItem, IOutgoingDocumentBase document)
        {
            if (addresseesItem.DeliveryMethod != null && addresseesItem.DeliveryMethod.Sid == Constants.MailDeliveryMethod.Exchange)
            {
                var boxes = addresseesItem.Correspondent.ExchangeBoxes
                            .Where(b => b.Status == Sungero.Parties.CounterpartyExchangeBoxes.Status.Active)
                            .Where(b => Equals(b.Box.BusinessUnit, document.BusinessUnit))
                            .Select(b => b.Box.ExchangeService.Name).Distinct();
                return(boxes.Any()
          ? string.Join(", ", boxes)
          : string.Empty);
            }
            var result = new List <string>();

            var postalAddress = string.IsNullOrEmpty(addresseesItem.Correspondent.PostalAddress)
        ? addresseesItem.Correspondent.LegalAddress
        : addresseesItem.Correspondent.PostalAddress;

            if (!string.IsNullOrEmpty(postalAddress))
            {
                result.Add(string.Format(Docflow.Reports.Resources.DistributionSheetReport.ContactsInformationPostalAddressTemplate, postalAddress));
            }

            var fax = addresseesItem.Addressee != null
        ? addresseesItem.Addressee.Fax
        : string.Empty;

            if (!string.IsNullOrEmpty(fax))
            {
                result.Add(string.Format(Docflow.Reports.Resources.DistributionSheetReport.ContactsInformationFaxTemplate, fax));
            }

            var email = addresseesItem.Addressee != null && !string.IsNullOrEmpty(addresseesItem.Addressee.Email)
        ? addresseesItem.Addressee.Email
        : addresseesItem.Correspondent.Email;

            if (!string.IsNullOrEmpty(email))
            {
                result.Add(string.Format(Docflow.Reports.Resources.DistributionSheetReport.ContactsInformationEmailTemplate, email));
            }

            return(result.Any()
        ? string.Join(Environment.NewLine, result)
        : string.Empty);
        }