Exemplo n.º 1
0
        public bool GenerateXML()
        {
            bool isGenerated = false;

            try
            {
                MS.GeneraLog.GeneracionXML("-----  Inicio de Generación de Archivo: " + MS.XMLIFileLocation);
                XmlSerializer           mySerializer = new XmlSerializer(typeof(RetentionType));
                XmlSerializerNamespaces ns           = getNamespaces();
                XmlWriterSettings       setting      = getSettings();

                RetentionType ret = new RetentionType();

                ret.UBLExtensions   = getUBLExtensions();
                ret.UBLVersionID    = getUBLVersionID();
                ret.CustomizationID = getCustomizationID();
                ret.Signature       = getSignatureType();
                ret.ID                              = getID();
                ret.IssueDate                       = getIssueDate();
                ret.AgentParty                      = getAgentParty();
                ret.ReceiverParty                   = getReceiverParty();
                ret.SUNATRetentionSystemCode        = getSUNATRetentionSystemCode();
                ret.SUNATRetentionPercent           = getSUNATRetentionPercent();
                ret.Note                            = getNote();
                ret.TotalInvoiceAmount              = getTotalInvoiceAmount();
                ret.SUNATTotalPaid                  = getSUNATTotalPaid();
                ret.SUNATRetentionDocumentReference = getSUNATRetentionDocumentReference();

                StringWriterWithEncoding iso88591StringWriter = new StringWriterWithEncoding(ISO_8859_1);
                XmlSerializer            serializer           = new XmlSerializer(typeof(RetentionType));
                XmlWriter writerx = XmlWriter.Create(iso88591StringWriter, setting);
                serializer.Serialize(writerx, ret, ns);

                XMLI = iso88591StringWriter.ToString();

                XMLI = XMLI.Replace("&lt;", "<");
                XMLI = XMLI.Replace("&gt;", ">");
                XMLI = XMLI.Replace("&amp;", "&");

                using (StreamWriter sw = new StreamWriter(MS.XMLIFileLocation, false, ISO_8859_1))
                {
                    sw.Write(XMLI);
                }

                SXMLI = GenerateStreamFromString(XMLI);

                isGenerated = true;
            }
            catch (Exception ex)
            {
                MS.GeneraLog.GeneracionXML("Ocurrió un error al momento de general el XML Inicial");
                MS.GeneraLog.GeneracionXML("Error: " + ex.Message);
            }
            return(isGenerated);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Genera Documento de Retencion.
        /// </summary>
        /// <param name="doc">Retention UBL2.0</param>
        /// <returns>XML</returns>
        public XmlFileResult GenerateDocRetention(RetentionType doc)
        {
            var filename = $"{doc.AgentParty.PartyIdentification[0].ID.Value}-20-{doc.ID.Value}";

            return(new XmlFileResult
            {
                Success = true,
                FileName = filename,
                Content = UtilsXmlDoc.GenFile(ref _result, doc, _certificado)
            });
        }
Exemplo n.º 3
0
        public RetentionType CreateNew(RetentionDirection id)
        {
            var newRetentionType = new RetentionType()
            {
                Id   = Guid.NewGuid(),
                Rate = 0,
                RetentionDirection = id,
                Status             = RetentionStatus.InActive
            };

            erpNodeDBContext.RetentionTypes.Add(newRetentionType);
            organization.SaveChanges();
            return(newRetentionType);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sets the retention policy of items in the specified conversation. Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="contextFolderId">The Id of the folder items must belong to in order for their retention policy to
 /// be set. If contextFolderId is null, the retention policy of items across the entire mailbox are set.</param>
 /// <param name="retentionPolicyType">Retention policy type.</param>
 /// <param name="retentionPolicyTagId">Retention policy tag id.  Null will clear the policy.</param>
 public void SetRetentionPolicyForItemsInConversation(
     FolderId contextFolderId,
     RetentionType retentionPolicyType,
     Guid?retentionPolicyTagId)
 {
     this.Service.SetRetentionPolicyForItemsInConversations(
         new KeyValuePair <ConversationId, DateTime?>[]
     {
         new KeyValuePair <ConversationId, DateTime?>(
             this.Id,
             this.GlobalLastDeliveryTime)
     },
         contextFolderId,
         retentionPolicyType,
         retentionPolicyTagId)[0].ThrowIfNecessary();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sets the retention policy of items in the specified conversation. Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="contextFolderId">The Id of the folder items must belong to in order for their retention policy to
 /// be set. If contextFolderId is null, the retention policy of items across the entire mailbox are set.</param>
 /// <param name="retentionPolicyType">Retention policy type.</param>
 /// <param name="retentionPolicyTagId">Retention policy tag id.  Null will clear the policy.</param>
 public async System.Threading.Tasks.Task SetRetentionPolicyForItemsInConversation(
     FolderId contextFolderId,
     RetentionType retentionPolicyType,
     Guid?retentionPolicyTagId)
 {
     (await this.Service.SetRetentionPolicyForItemsInConversations(
          new KeyValuePair <ConversationId, DateTime?>[]
     {
         new KeyValuePair <ConversationId, DateTime?>(
             this.Id,
             this.GlobalLastDeliveryTime)
     },
          contextFolderId,
          retentionPolicyType,
          retentionPolicyTagId).ConfigureAwait(false))[0].ThrowIfNecessary();
 }
 /// <summary>
 /// Sets the retention policy of items in the specified conversation. Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="contextFolderId">The Id of the folder items must belong to in order for their retention policy to
 /// be set. If contextFolderId is null, the retention policy of items across the entire mailbox are set.</param>
 /// <param name="retentionPolicyType">Retention policy type.</param>
 /// <param name="retentionPolicyTagId">Retention policy tag id.  Null will clear the policy.</param>
 public void SetRetentionPolicyForItemsInConversation(
     FolderId contextFolderId,
     RetentionType retentionPolicyType,
     Guid? retentionPolicyTagId)
 {
     this.Service.SetRetentionPolicyForItemsInConversations(
         new KeyValuePair<ConversationId, DateTime?>[]
         {
             new KeyValuePair<ConversationId, DateTime?>(
                 this.Id,
                 this.GlobalLastDeliveryTime)
         },
         contextFolderId,
         retentionPolicyType,
         retentionPolicyTagId)[0].ThrowIfNecessary();
 }
Exemplo n.º 7
0
 public RetentionType CreateNew(RetentionType type)
 {
     erpNodeDBContext.RetentionTypes.Add(type);
     return(type);
 }