/// <summary> /// Sevk irsaliyesi'nin(Despatch Advice) UBL' ini oluşturma /// </summary> /// <returns>Sevk İrsaliyesi UBL'i</returns> public DespatchAdviceType CreateDespactAdvice(string vknTckn, DateTime tarih1, string irsaliyeId = null) { //Sevk irsaliyesi kalem sayısını random olarak üretme Random rnd = new Random(); int lineNumber = rnd.Next(1, 10); DespatchAdviceType eIrsaliye = GetDespatchHeader(lineNumber, tarih1, irsaliyeId); eIrsaliye.OrderReference = GetOrderReference(); eIrsaliye.AdditionalDocumentReference = GetDocumentReference(); eIrsaliye.Signature = GetSignature(); switch (vknTckn.Length) { case 10: eIrsaliye.DespatchSupplierParty = GetSupplierParty(vknTckn, "VKN"); eIrsaliye.DeliveryCustomerParty = GetCustomerParty(vknTckn, "VKN"); break; case 11: eIrsaliye.DespatchSupplierParty = GetSupplierParty(vknTckn, "TCKN"); eIrsaliye.DeliveryCustomerParty = GetCustomerParty(vknTckn, "TCKN"); break; } eIrsaliye.Shipment = GetShipment(lineNumber); eIrsaliye.DespatchLine = GetDespatchLine(lineNumber); return(eIrsaliye); }
public int insertDespatchOnDbFromUbl(DespatchAdviceType despatchUbl, string xmlPath) { using (DatabaseContext databaseContext = new DatabaseContext()) { DespatchAdvices createdDespatch = new DespatchAdvices(); createdDespatch.ID = despatchUbl.ID.Value; createdDespatch.uuid = despatchUbl.UUID.Value; createdDespatch.direction = EI.Direction.DRAFT.ToString(); createdDespatch.draftFlag = true; //biz olusturduk servısten cekmedıgımız ıcın true createdDespatch.issueDate = despatchUbl.IssueDate.Value; createdDespatch.profileId = despatchUbl.ProfileID.Value; createdDespatch.senderVkn = despatchUbl.DespatchSupplierParty.Party.PartyIdentification.First().ID.Value; //sıfırıncı ındexde tc ya da vkn tutuluyor createdDespatch.receiverVkn = despatchUbl.DeliveryCustomerParty.Party.PartyIdentification.First().ID.Value; createdDespatch.cDate = despatchUbl.IssueDate.Value; createdDespatch.envelopeIdentifier = ""; createdDespatch.stateNote = nameof(EI.StateNote.CREATED); createdDespatch.status = ""; createdDespatch.gibStatusCode = 0; createdDespatch.gibStatusDescription = ""; createdDespatch.statusCode = ""; createdDespatch.folderPath = xmlPath; createdDespatch.typeCode = ""; createdDespatch.shipmentDate = despatchUbl.Shipment.Delivery.Despatch.ActualDespatchDate.Value; createdDespatch.shipmentTime = despatchUbl.Shipment.Delivery.Despatch.ActualDespatchTime.Value.ToString(); databaseContext.despatchAdvices.Add(createdDespatch); return(databaseContext.SaveChanges()); } }
public DespatchAdviceUbl(int lineCount, DateTime despatchDate, DateTime despatchTime, string orderId, DateTime orderDate) { baseDespatchUbl = new DespatchAdviceType(); createDespatchHeader(despatchDate, despatchTime, lineCount); createOrderReference(orderId, orderDate); createDocumentReference(); createSignature(); }
/// <summary> /// Sevk irsaliyesi (Despatch Advice) UBL'inin ilk alanlarını oluşturma /// </summary> /// <returns>UBL'in Alanları</returns> private DespatchAdviceType GetDespatchHeader(int lineNumber, DateTime tarih1, string irsaliyeId = null) { XmlDocument doc = new XmlDocument(); doc.LoadXml("<xml />"); var eIrsaliye = new DespatchAdviceType { UBLExtensions = new[] //UBL Dijital İmza Düğümü { new UBLExtensionType { ExtensionContent = doc.DocumentElement } }, UBLVersionID = new UBLVersionIDType { Value = "2.1" }, // uluslararası fatura standardı 2.1 CustomizationID = new CustomizationIDType { Value = "TR1.2.1" }, // GİB UBLTR olarak isimlendirdiği Türkiye'ye özgü 1.2.1 eİrsaliye formatını kullanıyor. ProfileID = new ProfileIDType { Value = "TEMELIRSALIYE" }, //Kullanılan Senaryo ID = irsaliyeId != null || irsaliyeId != "" ? new IDType { Value = irsaliyeId } : null, // ID = new IDType { Value = "GIB2018000000001" }, //Sevk irsaliyesine Ait Numara CopyIndicator = new CopyIndicatorType { Value = false }, // Sevk İrsaliyesinin Asıl veya Suret Bilgisi UUID = new UUIDType { Value = Guid.NewGuid().ToString() }, //Sevk İrsaliyesinin Evrensel Tekliğini Sağlayan Numara IssueDate = new IssueDateType { Value = tarih1 }, //Sevk İrsaliyesinin Düzenleme Tarihi IssueTime = new IssueTimeType { Value = default(DateTime).AddHours(11).AddMinutes(20) }, //Sevk İrsaliyesinin Düzenleme Zamanı DespatchAdviceTypeCode = new DespatchAdviceTypeCodeType { Value = "SEVK" }, //Sevk İrsaliyesinin Tip Kodu Note = new[] //Sevk İrsaliyesi İle İlgili Genel Açıklamalar { new NoteType { Value = "Mallar teslim edildi.." } }, LineCountNumeric = new LineCountNumericType { Value = lineNumber } //Sevk İrsaliyesi Kalem Sayısı }; return(eIrsaliye); }
/// <summary> /// Genera y Firma Documento de Guia de Remision. /// </summary> /// <param name="doc">Guia de Remision UBL2.1</param> /// <returns>XML</returns> public XmlFileResult GenerateDocGuia(DespatchAdviceType doc) { var filename = $"{doc.DespatchSupplierParty.CustomerAssignedAccountID.Value}-09-{doc.ID.Value}"; return(new XmlFileResult { Success = true, FileName = filename, Content = UtilsXmlDoc.GenFile(ref _result, doc, _certificado) }); }
public void DespatchAdviceType_Sample_Serialize() { var despatch = new DespatchAdviceType { UUID = new Common.UUIDType() { Value = Guid.NewGuid().ToString() }, UBLVersionID = new Common.UBLVersionIDType() { Value = "2.1" }, CustomizationID = new Common.CustomizationIDType() { Value = "TR1.2" }, ProfileID = new Common.ProfileIDType() { Value = "TEMELIRSALIYE" }, ID = new Common.IDType() { Value = "IRS20200000000001" }, CopyIndicator = new Common.CopyIndicatorType() { Value = false } }; XmlSerializer xmlSerializer = new XmlSerializer(typeof(DespatchAdviceType)); var stream = new MemoryStream(); xmlSerializer.Serialize(stream, despatch, new UblTrNamespaces()); File.WriteAllBytes(@"C:\Temp\irsalite.xml", stream.ToArray()); stream.Seek(0, SeekOrigin.Begin); var deserializedDespatch = (DespatchAdviceType)xmlSerializer.Deserialize(stream); Assert.AreEqual(despatch.ID.Value, deserializedDespatch.ID.Value); Assert.AreEqual(despatch.UUID.Value, deserializedDespatch.UUID.Value); Assert.AreEqual(despatch.CustomizationID.Value, deserializedDespatch.CustomizationID.Value); Assert.AreEqual(despatch.CopyIndicator.Value, deserializedDespatch.CopyIndicator.Value); Assert.AreEqual(despatch.ProfileID.Value, deserializedDespatch.ProfileID.Value); }
public static string writeDiscDespatchConvertUblToXml(DespatchAdviceType createdUBL) { //olusturulan xmli diske kaydediyor string xmlPath = FolderControl.createDespatchDocPath(createdUBL.ID.Value, nameof(EI.Direction.DRAFT), nameof(EI.DocumentType.XML)); createInboxIfDoesNotExist(Path.GetDirectoryName(xmlPath)); //dosya yolu yoksa olustur using (FileStream stream = new FileStream(xmlPath, FileMode.Create)) { XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType()); xmlSerializer.Serialize(stream, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace()); } return(xmlPath); //// ////xmli strıng durunde return edıyoruz contentını dondurmek ıcın asagıdakı kodu acarız //using (StringWriter textWriter = new StringWriter()) //{ // XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType()); // xmlSerializer.Serialize(textWriter, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace()); // return textWriter.ToString(); //} }
public static DespatchAdviceType Create() { var doc = new DespatchAdviceType { UBLVersionID = "2.0", CustomizationID = "urn:oasis:names:specification:ubl:xpath:DespatchAdvice-2.0:sbs-1.0-draft", ProfileID = "bpid:urn:oasis:names:draft:bpss:ubl-2-sbs-despatch-advice-notification-draft", ID = "565899", CopyIndicator = false, UUID = "88C7280E-8F10-419F-9949-8EFFFA2842B8", IssueDate = "2005-06-20", DocumentStatusCode = "NoStatus", DespatchAdviceTypeCode = "delivery", Note = new List <TextType>() { new TextType { Value = "sample" } }, OrderReference = new List <OrderReferenceType>() { new OrderReferenceType { ID = "AEG012345", SalesOrderID = "CON0095678", UUID = "6E09886B-DC6E-439F-82D1-7CCAC7F4E3B1", IssueDate = "2005-06-20" } }, DespatchSupplierParty = new SupplierPartyType { CustomerAssignedAccountID = "CO001", Party = new PartyType { PartyName = new List <PartyNameType>() { new PartyNameType { Name = "Consortial" } }, PostalAddress = new AddressType { StreetName = "Busy Street", BuildingName = "Thereabouts", BuildingNumber = "56A", CityName = "Farthing", PostalZone = "AA99 1BB", CountrySubentity = "Heremouthshire", AddressLine = new List <AddressLineType>() { new AddressLineType { Line = "The Roundabout" } }, Country = new CountryType { IdentificationCode = "GB" } }, PartyTaxScheme = new List <PartyTaxSchemeType>() { new PartyTaxSchemeType { RegistrationName = "Farthing Purchasing Consortium", CompanyID = "175 269 2355", ExemptionReason = new List <TextType>() { new TextType { Value = "N/A" } }, TaxScheme = new TaxSchemeType { ID = "VAT", TaxTypeCode = "VAT" } } }, Contact = new ContactType { Name = "Mrs Bouquet", Telephone = "0158 1233714", Telefax = "0158 1233856", ElectronicMail = "*****@*****.**" } } }, DeliveryCustomerParty = new CustomerPartyType { CustomerAssignedAccountID = "XFB01", SupplierAssignedAccountID = "GT00978567", Party = new PartyType { PartyName = new List <PartyNameType>() { new PartyNameType { Name = "IYT Corporation" } }, PostalAddress = new AddressType { StreetName = "Avon Way", BuildingName = "Thereabouts", BuildingNumber = "56A", CityName = "Bridgtow", PostalZone = "ZZ99 1ZZ", CountrySubentity = "Avon", AddressLine = new List <AddressLineType>() { new AddressLineType { Line = "3rd Floor, Room 5" } }, Country = new CountryType { IdentificationCode = "GB" } }, PartyTaxScheme = new List <PartyTaxSchemeType>() { new PartyTaxSchemeType { RegistrationName = "Bridgtow District Council", CompanyID = "12356478", ExemptionReason = new List <TextType>() { new TextType { Value = "Local Authority" } }, TaxScheme = new TaxSchemeType { ID = "UK VAT", TaxTypeCode = "VAT" } } }, Contact = new ContactType { Name = "Mr Fred Churchill", Telephone = "0127 2653214", Telefax = "0127 2653215", ElectronicMail = "*****@*****.**" } } }, Shipment = new ShipmentType { ID = "1", Consignment = new List <ConsignmentType>() { new ConsignmentType { ID = "1" } }, Delivery = new DeliveryType { DeliveryAddress = new AddressType { StreetName = "Avon Way", BuildingName = "Thereabouts", BuildingNumber = "56A", CityName = "Bridgtow", PostalZone = "ZZ99 1ZZ", CountrySubentity = "Avon", AddressLine = new List <AddressLineType>() { new AddressLineType { Line = "3rd Floor, Room 5" } }, Country = new CountryType { IdentificationCode = "GB" } }, RequestedDeliveryPeriod = new PeriodType { StartDate = "2005-06-20", StartTime = "10:30:47.0Z", EndDate = "2005-06-21", EndTime = "10:30:47.0Z" } } }, DespatchLine = new List <DespatchLineType>() { new DespatchLineType { ID = "1", Note = new List <TextType>() { new TextType { Value = "Mrs Green agreed to waive charge" } }, LineStatusCode = "NoStatus", DeliveredQuantity = new QuantityType { unitCode = "KGM", Value = 90M }, BackorderQuantity = new QuantityType { unitCode = "KGM", Value = 10M }, BackorderReason = new List <TextType>() { new TextType { Value = "lack of stock as explained on telephone today" } }, OrderLineReference = new List <OrderLineReferenceType>() { new OrderLineReferenceType { LineID = "1", SalesOrderLineID = "A", OrderReference = new OrderReferenceType { ID = "AEG012345", SalesOrderID = "CON0095678", UUID = "6E09886B-DC6E-439F-82D1-7CCAC7F4E3B1", IssueDate = "2005-06-20" } } }, Item = new ItemType { Description = new List <TextType>() { new TextType { Value = "Acme beeswax" } }, Name = "beeswax", BuyersItemIdentification = new ItemIdentificationType { ID = "6578489" }, SellersItemIdentification = new ItemIdentificationType { ID = "17589683" }, ItemInstance = new List <ItemInstanceType>() { new ItemInstanceType { LotIdentification = new LotIdentificationType { LotNumberID = "546378239", ExpiryDate = "2010-01-01" } } }, } } }, }; doc.Xmlns = new System.Xml.Serialization.XmlSerializerNamespaces(new[] { new XmlQualifiedName("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"), new XmlQualifiedName("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"), }); return(doc); }
private void IrsaliyeOlustur(Irsaliye irsaliyeBilgileri, IrsaliyeHareket irsaliyeHareket) { DespatchLineType[] IrsaliyeHareketleri() { var lines = new List <DespatchLineType>(); var line = new DespatchLineType { ID = new IDType { Value = "1" }, DeliveredQuantity = new DeliveredQuantityType { unitCode = "C62", Value = 20 }, OrderLineReference = new OrderLineReferenceType { LineID = new LineIDType { Value = Guid.NewGuid().ToString() } }, Note = new[] { new NoteType { Value = "Stok-0001" + " - " + "Masa Üstü Bilgisayar" } }, Item = new ItemType { Name = new NameType1 { Value = "Masa Üstü Bilgisayar" }, SellersItemIdentification = new ItemIdentificationType { ID = new IDType { Value = "149159" } } }, Shipment = new[] { new ShipmentType { ID = new IDType { }, GoodsItem = new[] { new GoodsItemType { /*ID=new IDType{}, * ValueAmount=new ValueAmountType { currencyID="TRY",Value=(decimal)20000},*/ InvoiceLine = new[] { new InvoiceLineType { ID = new IDType { }, InvoicedQuantity = new InvoicedQuantityType { Value = (decimal)0 }, LineExtensionAmount = new LineExtensionAmountType { currencyID = "TRY", Value = 20000 }, Item = new ItemType { Name = new NameType1 { } }, Price = new PriceType { PriceAmount = new PriceAmountType { currencyID = "TRY", Value = (decimal)1000, } } } }, } } } } }; lines.Add(line); return(lines.ToArray()); } var despatchAdviceType = new DespatchAdviceType { UBLExtensions = new[] { new UBLExtensionType() }, UBLVersionID = new UBLVersionIDType { Value = "2.1" }, CustomizationID = new CustomizationIDType { Value = "TR1.2" }, ProfileID = new ProfileIDType { Value = "TEMELIRSALIYE" }, ID = new IDType { Value = irsaliyeBilgileri.IrsaliyeNo }, CopyIndicator = new CopyIndicatorType { Value = false }, UUID = new UUIDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = irsaliyeBilgileri.Tarih }, IssueTime = new IssueTimeType { Value = irsaliyeBilgileri.Tarih }, DespatchAdviceTypeCode = new DespatchAdviceTypeCodeType { Value = "SEVK" }, Note = new[] { new NoteType { Value = "İş bu sevk irsaliyesi muhteviyatına 7 gün içerisinde itiraz edilmediği taktirde aynen kabul edilmiş sayılır" }, }, //LineCountNumeric = new LineCountNumericType { Value = 1 }, OrderReference = new[] { new OrderReferenceType { ID = new IDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = irsaliyeBilgileri.Tarih } } }, AdditionalDocumentReference = new[] { new DocumentReferenceType { ID = new IDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = irsaliyeBilgileri.Tarih }, DocumentTypeCode = new DocumentTypeCodeType { Value = "Katalog" }, DocumentType = new DocumentTypeType { Value = "Katalog Belgesi" } }, new DocumentReferenceType { ID = new IDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = irsaliyeBilgileri.Tarih }, DocumentTypeCode = new DocumentTypeCodeType { Value = "Kontrat" }, DocumentType = new DocumentTypeType { Value = "Kontrat Belgesi" } }, }, DespatchSupplierParty = new SupplierPartyType { Party = new PartyType { WebsiteURI = new WebsiteURIType { Value = "http://www.aaa.com.tr/" }, PartyIdentification = new[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "12388331521" } } }, PartyName = new PartyNameType { Name = new NameType1 { Value = "AAA Anonim Şirketi" } }, PostalAddress = new AddressType { ID = new IDType { Value = "2806632739" }, StreetName = new StreetNameType { Value = "Selvi Caddesi Sedir Sokak" }, BuildingNumber = new BuildingNumberType { Value = "75/A" }, CityName = new CityNameType { Value = "Denizli" }, CitySubdivisionName = new CitySubdivisionNameType { Value = "Merkezefendi" }, PostalZone = new PostalZoneType { Value = "06100" }, District = new DistrictType { Value = "Ihlamur Mahallesi" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } }, PhysicalLocation = new LocationType1 { ID = new IDType { Value = "Depo Şube" }, Address = new AddressType { ID = new IDType { Value = "1234567895" }, StreetName = new StreetNameType { Value = "Ihlamur Mahallesi Selvi Caddesi Sedir Sokak" }, BuildingNumber = new BuildingNumberType { Value = "79/A" }, CitySubdivisionName = new CitySubdivisionNameType { Value = "Balgat" }, CityName = new CityNameType { Value = "Ankara" }, PostalZone = new PostalZoneType { Value = "06800" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } } }, PartyTaxScheme = new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "Büyük Mükellefler" } } }, Contact = new ContactType { Telephone = new TelephoneType { Value = "(312) 621 1111" }, Telefax = new TelefaxType { Value = "(312) 621 1010" }, ElectronicMail = new ElectronicMailType { Value = "*****@*****.**" } }, } }, /*Signature=new[]{new SignatureType * { * ID=new IDType { schemeID= "VKN_TCKN",Value= "1288331521"}, * SignatoryParty=new PartyType * { * PartyIdentification=new[]{new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "1288331521" } }}, * PostalAddress = new AddressType * { * ID = new IDType { Value = "1288331521" }, * StreetName = new StreetNameType { Value = "Papatya Caddesi Yasemin Sokak" }, * BuildingNumber = new BuildingNumberType { Value = "75/A" }, * CityName = new CityNameType { Value = "Istanbul" }, * CitySubdivisionName = new CitySubdivisionNameType { Value = "Beşiktaş" }, * PostalZone = new PostalZoneType { Value = "34100" }, * District = new DistrictType { Value = "Ihlamur Mahallesi" }, * Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } * }, * }, * DigitalSignatureAttachment=new AttachmentType * { * ExternalReference=new ExternalReferenceType{URI=new URIType{Value="#Signature"}} * } * }, * },*/ DeliveryCustomerParty = new CustomerPartyType { Party = new PartyType { WebsiteURI = new WebsiteURIType { Value = "http://www.BBB.com.tr/" }, PartyIdentification = new[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "12388331234" } } }, PartyName = new PartyNameType { Name = new NameType1 { Value = "BBB Anonim Şirketi" } }, PostalAddress = new AddressType { ID = new IDType { Value = "1288331521" }, StreetName = new StreetNameType { Value = "Papatya Caddesi Yasemin Sokak" }, BuildingNumber = new BuildingNumberType { Value = "75/A" }, CityName = new CityNameType { Value = "Istanbul" }, CitySubdivisionName = new CitySubdivisionNameType { Value = "Beşiktaş" }, PostalZone = new PostalZoneType { Value = "34100" }, District = new DistrictType { Value = "Ihlamur Mahallesi" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } }, PartyTaxScheme = new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "Büyük Mükellefler" } } }, Contact = new ContactType { Telephone = new TelephoneType { Value = "(312) 621 7777" }, Telefax = new TelefaxType { Value = "(312) 621 7070" }, ElectronicMail = new ElectronicMailType { Value = "*****@*****.**" } }, } }, Shipment = new ShipmentType { ID = new IDType { Value = Guid.NewGuid().ToString() }, GoodsItem = new[] { new GoodsItemType { ValueAmount = new ValueAmountType { currencyID = "TRY", Value = 20000 }, } }, ShipmentStage = new[] { new ShipmentStageType { TransportMeans = new TransportMeansType { RoadTransport = new RoadTransportType { LicensePlateID = new LicensePlateIDType { schemeID = "DORSEPLAKA" } } }, DriverPerson = new[] { new PersonType { FirstName = new FirstNameType { Value = "Mehmet" }, FamilyName = new FamilyNameType { Value = "Öztürk" }, Title = new TitleType { Value = "Şoför" }, NationalityID = new NationalityIDType { schemeID = "TCKN", Value = "14922266699" } }, new PersonType { FirstName = new FirstNameType { Value = "Mustafa" }, FamilyName = new FamilyNameType { Value = "Öztürk" }, Title = new TitleType { Value = "Şoför" }, NationalityID = new NationalityIDType { schemeID = "TCKN", Value = "14922266600" } } }, }, }, Delivery = new DeliveryType { CarrierParty = new PartyType { PartyIdentification = new[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "1288331523" } } }, PartyName = new PartyNameType { Name = new NameType1 { Value = "CCC Lojistik Anonim" } }, PostalAddress = new AddressType { CitySubdivisionName = new CitySubdivisionNameType { Value = "Osmancık" }, CityName = new CityNameType { Value = "Çorum" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } } }, Despatch = new DespatchType { ActualDespatchDate = new ActualDespatchDateType { Value = DateTime.Now }, ActualDespatchTime = new ActualDespatchTimeType { Value = DateTime.Now } } }, TransportHandlingUnit = new[] { new TransportHandlingUnitType { TransportEquipment = new[] { new TransportEquipmentType { ID = new IDType { schemeID = "DORSEPLAKA", Value = "06DR4088" } }, new TransportEquipmentType { ID = new IDType { schemeID = "DORSEPLAKA", Value = "06DR4099" } } } }, } }, DespatchLine = IrsaliyeHareketleri(), }; if (irsaliyeHareket.KargoBilgileriGözüksünMü) { despatchAdviceType.Signature = new[] { new SignatureType { ID = new IDType { schemeID = "VKN_TCKN", Value = "1234567890" }, SignatoryParty = new PartyType { PartyIdentification = new [] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "1234567890" } } }, PostalAddress = new AddressType { Room = new RoomType { Value = "25" }, BlockName = new BlockNameType { Value = "A Blok" }, BuildingName = new BuildingNameType { Value = "Karanfil" }, BuildingNumber = new BuildingNumberType { Value = "345" }, CitySubdivisionName = new CitySubdivisionNameType { Value = "Çankaya" }, CityName = new CityNameType { Value = "Ankara" }, PostalZone = new PostalZoneType { Value = "06200" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } } }, DigitalSignatureAttachment = new AttachmentType { ExternalReference = new ExternalReferenceType { URI = new URIType { Value = "#Signature_" + irsaliyeBilgileri.IrsaliyeNo } } } }, }; } var settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }; settings.Encoding = Encoding.GetEncoding("UTF-8"); var ms = new MemoryStream(); var writer = XmlWriter.Create(ms, settings); var srl = new XmlSerializer(despatchAdviceType.GetType()); srl.Serialize(writer, despatchAdviceType, XmlNameSpace()); ms.Flush(); ms.Seek(0, SeekOrigin.Begin); var srRead = new StreamReader(ms); var readXml = srRead.ReadToEnd(); var path = Path.Combine($@"{Application.StartupPath}\EArsivFaturalar\{ despatchAdviceType.ID.Value }.xml"); void EFaturaOlustur() { using (var sWriter = new StreamWriter(path, false, Encoding.UTF8)) { sWriter.Write(readXml); sWriter.Close(); } } if (!Directory.Exists($@"{Application.StartupPath}\EArsivFaturalar")) { Directory.CreateDirectory($@"{Application.StartupPath}\EArsivFaturalar"); } if (!File.Exists($@"{Application.StartupPath}\EArsivFaturalar\{ despatchAdviceType.ID.Value }.xml")) { EFaturaOlustur(); } else if (MessageBox.Show($@"{ despatchAdviceType.ID.Value }.xml dosyasıdaha önce oluşturulmuş. Yeniden oluşturulsun mu?", "Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { EFaturaOlustur(); } if (MessageBox.Show($@"Fatura oluşturma işlemi başarılı bir şekilde tamamlandı. Faturalar '{Application.StartupPath}\EArsivFaturalar' konumunda oluşturuldu. Konumu açmak istiyor musununz?", "Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) { return; } Process.Start(Application.StartupPath + "\\EArsivFaturalar"); XmlSerializerNamespaces XmlNameSpace() { var ns = new XmlSerializerNamespaces(); ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); //ns.Add("schemaLocation", "urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2 ../xsdrt/maindoc/UBL-DespatchAdvice-2.1.xsd"); //ns.Add("urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2"); ns.Add("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"); ns.Add("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"); ns.Add("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"); ns.Add("n4", "http://www.altova.com/samplexml/other-namespace#"); /*ns.Add("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"); * ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); * ns.Add("xades", "http://uri.etsi.org/01903/v1.3.2#"); * ns.Add("udt", "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"); * //ns.Add("ubltr", "urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents"); * //ns.Add("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"); * ns.Add("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"); * ns.Add("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"); * ns.Add("ccts", "urn:un:unece:uncefact:documentation:2"); * ns.Add("n4", "http://www.altova.com/samplexml/other-namespace#");*/ return(ns); } }
public byte[] GenerateDespatchUbl(DespatchData data) { var despatch = new DespatchAdviceType { UUID = new UUIDType() { Value = Guid.NewGuid().ToString() }, UBLVersionID = new UBLVersionIDType() { Value = "2.1" }, CustomizationID = new CustomizationIDType() { Value = "TR1.2" }, ProfileID = new ProfileIDType() { Value = "TEMELIRSALIYE" }, ID = new IDType() { Value = data.IRSALIYE_NO }, //Irsaliye No CopyIndicator = new CopyIndicatorType() { Value = false }, IssueDate = new IssueDateType { Value = DateTime.Now.Date }, IssueTime = new IssueTimeType { Value = DateTime.Now }, DespatchAdviceTypeCode = new DespatchAdviceTypeCodeType { Value = "SEVK" }, UBLExtensions = new UBLExtensionType[] { new UBLExtensionType { ExtensionContent = null } }, DespatchSupplierParty = new SupplierPartyType() { Party = new PartyType { WebsiteURI = new WebsiteURIType { Value = "www.firmaadi.com" }, PartyIdentification = new PartyIdentificationType[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = data.GONDEREN_VERGINO } } }, PartyName = new PartyNameType { Name = new NameType1 { Value = data.GONDEREN_UNVAN } }, PostalAddress = new AddressType { CitySubdivisionName = new CitySubdivisionNameType { Value = data.GONDEREN_ILCE }, CityName = new CityNameType { Value = data.GONDEREN_IL }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } }, PartyTaxScheme = new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = data.GONDEREN_VERGIDAIRESI } } } } }, DeliveryCustomerParty = new CustomerPartyType { Party = new PartyType { PartyIdentification = new PartyIdentificationType[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = !string.IsNullOrEmpty(data.ALICI_VERGINO)?data.ALICI_VERGINO:"5555555555" } } }, PartyName = new PartyNameType { Name = new NameType1 { Value = !string.IsNullOrEmpty(data.ALICI_VERGINO) ? data.ALICI_UNVAN : "Muhtelif Müşteriler" } }, PostalAddress = new AddressType { CitySubdivisionName = new CitySubdivisionNameType { Value = data.ALICI_ILCE }, CityName = new CityNameType { Value = data.ALICI_IL }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } }, PartyTaxScheme = new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = data.ALICI_VERGIDAIRESI } } } } }, Shipment = new ShipmentType { ID = new IDType { Value = "" }, GoodsItem = new GoodsItemType[] { new GoodsItemType { HazardousRiskIndicator = new HazardousRiskIndicatorType { Value = false, }, ValueAmount = new ValueAmountType { currencyID = "TRY", // Toplam_Tutar_Bilgisi Value = 0 }, CustomsImportClassifiedIndicator = new CustomsImportClassifiedIndicatorType { Value = false } } }, Delivery = new DeliveryType { Despatch = new DespatchType { ActualDespatchDate = new ActualDespatchDateType { Value = DateTime.Now.Date }, ActualDespatchTime = new ActualDespatchTimeType { Value = DateTime.Now } }, CarrierParty = new PartyType { PartyIdentification = new PartyIdentificationType[] { new PartyIdentificationType { ID = new IDType { schemeID = "", Value = data.CarrierInfo.VERGINO } } }, PartyName = new PartyNameType { Name = new NameType1 { Value = data.CarrierInfo.FIRMA_ADI } }, PostalAddress = new AddressType { CitySubdivisionName = new CitySubdivisionNameType { Value = data.CarrierInfo.ILCE }, CityName = new CityNameType { Value = data.CarrierInfo.IL }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } } } } }, DespatchLine = data.Details.Select(d => new DespatchLineType { ID = new IDType { Value = d.SIRANO }, DeliveredQuantity = new DeliveredQuantityType { unitCode = "NIU", Value = d.ADET }, OrderLineReference = new OrderLineReferenceType { LineID = new LineIDType { Value = d.SIRANO } }, Item = new ItemType { Name = new NameType1 { Value = d.ACIKLAMA }, SellersItemIdentification = new ItemIdentificationType { ID = new IDType { Value = d.IRS_SATIR_ID//IRSALIYE_SATIR_ID } } } }).ToArray() }; XmlSerializer xmlSerializer = new XmlSerializer(typeof(DespatchAdviceType)); using (MemoryStream output = new MemoryStream()) { xmlSerializer.Serialize(output, despatch, new Common.UblGenerator()); return(output.ToArray()); } }