Skip to content

Commit

Permalink
Corrige errores menores
Browse files Browse the repository at this point in the history
  • Loading branch information
FacuMasino committed Jul 20, 2024
1 parent 59a5904 commit 6659843
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
4 changes: 2 additions & 2 deletions ImprimirPolizas/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2")]
[assembly: AssemblyFileVersion("1.2")]
[assembly: AssemblyVersion("1.2.1")]
[assembly: AssemblyFileVersion("1.2.1")]
6 changes: 6 additions & 0 deletions ImprimirPolizas/ScTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ CancellationToken ctsToken
{
using (HttpContent content = res.Content)
{
if (res.StatusCode != HttpStatusCode.OK)
{
throw new Exception(
"Error en la solicitud al servidor, no se pudo obtener la condición fiscal."
);
}
var resData = await content.ReadAsStringAsync();
// MessageBox.Show(resData);
return ((bool)JObject.Parse(resData)["requiresInvoice"]) || false;
Expand Down
50 changes: 28 additions & 22 deletions ImprimirPolizas/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -57,6 +58,9 @@ private void Form1_Load(object sender, EventArgs e)
// Habilitar opciones iniciales
options[0] = (int)ScTools.DownloadOpt.policy;
options[1] = (int)ScTools.DownloadOpt.policyCard;

string assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
this.Text += $" - v{assemblyVersion}";
}

private async void EnableWhenReady()
Expand Down Expand Up @@ -188,32 +192,27 @@ private void TxtPolicy_TextChanged(object sender, EventArgs e)

private async Task NotifyInvoiceRequired(string policyNumber)
{
ScTools.DownloadOpt opt = ScTools.DownloadOpt.invoice;

try
{
if (!await ScTools.requiresInvoice(policyNumber, cts.Token))
return;
}
catch (OperationCanceledException)
{
return; // ignorar si se cancela
}

GetFocused(); // traer ventana al frente
string actualAction = rbPrint.Checked ? "imprimir" : "descargar";
DialogResult result = MessageBox.Show(
"La categoría del socio es R.I o Monotributo\n"
+ $"Desea {actualAction} la Factura?",
"Aviso",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly
);
if (result == DialogResult.No)
return;
ScTools.DownloadOpt opt = ScTools.DownloadOpt.invoice;
try
{
GetFocused(); // traer ventana al frente
string actualAction = rbPrint.Checked ? "imprimir" : "descargar";
DialogResult result = MessageBox.Show(
"La categoría del socio es R.I o Monotributo\n"
+ $"Desea {actualAction} la Factura?",
"Aviso",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly
);
if (result == DialogResult.No)
return;

cts.Token.ThrowIfCancellationRequested();
ChangeCheckFromTask(chkInvoice, true);
SetIconStatus(ScTools.DownloadOpt.invoice, IconState.Loading);
Expand All @@ -229,9 +228,16 @@ private async Task NotifyInvoiceRequired(string policyNumber)
}
SetIconStatus(opt, IconState.Ready);
}
catch (OperationCanceledException)
{
return; // ignorar si se cancela
}
catch (Exception ex)
{
SetIconStatus(opt, IconState.Error);
if (rbPrint.Checked)
{
SetIconStatus(opt, IconState.Error);
}
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Expand Down
4 changes: 2 additions & 2 deletions autoupdater.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2</version>
<url>https://github.com/FacuMasino/imprimir-polizas-utility/releases/download/v1.2/ImprimirPolizasV1.2.zip</url>
<version>1.2.1</version>
<url>https://github.com/FacuMasino/imprimir-polizas-utility/releases/download/v.1.2.1/ImprimirPolizasV1.2.1.zip</url>
<mandatory mode="2">true</mandatory>
</item>

0 comments on commit 6659843

Please sign in to comment.