public static void GetPrintXml(XDocument xml, string customLabelsLang) { string emptyGuid = Guid.Empty.ToString(); var foreignKeys = from node in xml.Root.Descendants() where node.Name.LocalName != "id" && node.Name.LocalName.EndsWith("Id", StringComparison.Ordinal) && node.Value != emptyGuid select node; foreach (XElement element in foreignKeys) { ILabeledDictionaryBusinessObject bo = null; switch (element.Name.LocalName) { case "contractorFieldId": bo = DictionaryMapper.Instance.GetContractorField(new Guid(element.Value)); element.Add(new XAttribute("name", ((ContractorField)bo).Name)); break; case "documentFieldId": bo = DictionaryMapper.Instance.GetDocumentField(new Guid(element.Value)); DocumentField df = (DocumentField)bo; element.Add(new XAttribute("name", df.Name)); //jezeli jest to id magazynu przeciwnego to dolaczamy jego label i symbol if (df.Name == DocumentFieldName.ShiftDocumentAttribute_OppositeWarehouseId.ToString()) { Warehouse whOp = DictionaryMapper.Instance.GetWarehouse(new Guid(element.Parent.Element("value").Value)); element.Add(new XAttribute("warehouseLabel", BusinessObjectHelper.GetBusinessObjectLabelInUserLanguage(whOp, customLabelsLang).Value)); element.Add(new XAttribute("warehouseSymbol", whOp.Symbol)); } //jeśli jest atrybut typu select to zamiast wartości musi się pojawić etykieta odpowiadająca tej wartości w języku usera if (df.DataType == DataType.Select) { XElement valueElement = element.Parent.Element(XmlName.Value); if (valueElement != null) { valueElement.Value = BusinessObjectHelper.GetSelectedValueInUserLanguage(df, valueElement.Value); } } break; case "jobPositionId": bo = DictionaryMapper.Instance.GetJobPosition(new Guid(element.Value)); break; case "countryId": case "nipPrefixCountryId": bo = DictionaryMapper.Instance.GetCountry(new Guid(element.Value)); element.Add(new XAttribute("symbol", ((Country)bo).Symbol)); break; case "contractorRelationTypeId": bo = DictionaryMapper.Instance.GetContractorRelationType(new Guid(element.Value)); break; case "itemFieldId": bo = DictionaryMapper.Instance.GetItemField(new Guid(element.Value)); element.Add(new XAttribute("name", ((ItemField)bo).Name)); break; case "itemRAVTypeId": bo = DictionaryMapper.Instance.GetItemRelationAttrValueType(new Guid(element.Value)); break; case "itemRelationId": bo = DictionaryMapper.Instance.GetItemRelationType(new Guid(element.Value)); break; case "itemTypeId": bo = DictionaryMapper.Instance.GetItemType(new Guid(element.Value)); break; case "unitId": bo = DictionaryMapper.Instance.GetUnit(new Guid(element.Value)); element.Add(new XAttribute("symbol", BusinessObjectHelper.GetBusinessObjectLabelInUserLanguage(bo, customLabelsLang).Attribute("symbol").Value)); break; case "unitTypeId": bo = DictionaryMapper.Instance.GetUnitType(new Guid(element.Value)); break; case "vatRateId": bo = DictionaryMapper.Instance.GetVatRate(new Guid(element.Value)); VatRate vr = (VatRate)bo; element.Add(new XAttribute("fiscalSymbol", vr.FiscalSymbol)); element.Add(new XAttribute("symbol", vr.Symbol)); break; case "documentCurrencyId": case "systemCurrencyId": case "paymentCurrencyId": bo = DictionaryMapper.Instance.GetCurrency(new Guid(element.Value)); element.Add(new XAttribute("symbol", ((Currency)bo).Symbol)); break; case "documentTypeId": bo = DictionaryMapper.Instance.GetDocumentType(new Guid(element.Value)); element.Add(new XAttribute("symbol", ((DocumentType)bo).Symbol)); break; case "issuePlaceId": bo = null; IssuePlace issuePlace = DictionaryMapper.Instance.GetIssuePlace(new Guid(element.Value)); if (issuePlace == null) { throw new ArgumentNullException("issuePlaceId"); } element.Add(new XAttribute("label", issuePlace.Name)); break; case "paymentMethodId": bo = DictionaryMapper.Instance.GetPaymentMethod(new Guid(element.Value)); element.Add(new XAttribute("isIncrementingDueAmount", ((PaymentMethod)bo).IsIncrementingDueAmount ? "1" : "0")); break; case "warehouseId": bo = DictionaryMapper.Instance.GetWarehouse(new Guid(element.Value)); Warehouse wh = (Warehouse)bo; element.Add(new XAttribute("symbol", wh.Symbol)); break; case "financialRegisterId": FinancialRegister fr = DictionaryMapper.Instance.GetFinancialRegister(new Guid(element.Value)); bo = fr; element.Add(new XAttribute("registerCategory", ((int)fr.RegisterCategory).ToString(CultureInfo.InvariantCulture))); Guid systemCurrencyId = ConfigurationMapper.Instance.SystemCurrencyId; Currency currency = DictionaryMapper.Instance.GetCurrency(fr.CurrencyId); element.Add(new XAttribute("currencyId", currency.Id.ToUpperString())); element.Add(new XAttribute("currencySymbol", currency.Symbol)); element.Add(new XAttribute("systemCurrencyId", systemCurrencyId.ToUpperString())); if (!String.IsNullOrEmpty(fr.AccountingAccount)) { element.Add(new XAttribute("accountingAccount", fr.AccountingAccount)); } if (!String.IsNullOrEmpty(fr.BankAccountNumber)) { element.Add(new XAttribute("bankAccountNumber", fr.BankAccountNumber)); } break; case "containerTypeId": bo = DictionaryMapper.Instance.GetContainerType(new Guid(element.Value)); break; case "servicePlaceId": element.Add(new XAttribute("label", DictionaryMapper.Instance.GetServicePlace(new Guid(element.Value)).Name)); break; case "itemGroupId": string path = DictionaryMapper.Instance.GetItemGroupMembershipPath(element.Value); if (path != null) { element.Add(new XAttribute("path", path)); } break; } if (bo != null) { element.Add(new XAttribute("label", BusinessObjectHelper.GetBusinessObjectLabelInUserLanguage(bo, customLabelsLang).Value)); } } }
/// <summary> /// Gets the business object label in user language. /// </summary> /// <param name="businessObject">The business object that contains xmlLabels node.</param> /// <returns>Label in user language version.</returns> public static XElement GetBusinessObjectLabelInUserLanguage(ILabeledDictionaryBusinessObject businessObject) { return(BusinessObjectHelper.GetBusinessObjectLabelInUserLanguage(businessObject, null)); }