This commit is contained in:
@@ -451,9 +451,16 @@
|
||||
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender5" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaFAdd" Width="350px"></ajax:ValidatorCalloutExtender>
|
||||
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender6" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaFAdd" Width="350px"></ajax:ValidatorCalloutExtender>
|
||||
</div>
|
||||
<div class="col-md-2" style="padding-top: 14px; padding-left: 0px;">
|
||||
<div class="input-group input-sm input-small date date-picker " style="padding-left: 0px;" data-date-format="dd/mm/yyyy">
|
||||
<span class="input-group-btn ">
|
||||
<asp:LinkButton ID="LnkFechaFAdd" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<asp:LinkButton ID="LnkSolicitarSat" OnClick="LnkSolicitarSat_Click" runat="server">Solicitar</asp:LinkButton>
|
||||
<asp:LinkButton ID="LnkSolicitarSat" CssClass="btn btn-primary" OnClick="LnkSolicitarSat_Click" runat="server">Solicitar</asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
@@ -44,9 +49,9 @@ public partial class SAT_SolicitudesNominaSat : ClsPaginas
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
TxtRpdFechaInicio.Text = string.Format("01/01/{0}", DateTime.Now.Year - 1);
|
||||
TxtRpdFechaFin.Text = string.Format("31/12/{0}", DateTime.Now.Year - 1);
|
||||
LnkConsultar_Click(null, null);
|
||||
TxtRpdFechaInicio.Text = string.Format("01/{0:MM/yyyy}", DateTime.Now.AddMonths(-1));
|
||||
TxtRpdFechaFin.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now.AddMonths(-1).LastDayOfMonth());
|
||||
//LnkConsultar_Click(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +179,9 @@ public partial class SAT_SolicitudesNominaSat : ClsPaginas
|
||||
}
|
||||
}
|
||||
UPModalViewSolicitudes.Update();
|
||||
var api = new GeneralesAPI();
|
||||
api.GeneraSolicitud();
|
||||
api.VerificaSolicitudesNominas();
|
||||
}
|
||||
protected void LnkShowSolicitudes_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -196,6 +204,9 @@ public partial class SAT_SolicitudesNominaSat : ClsPaginas
|
||||
using (ClsNominas nom = new ClsNominas())
|
||||
{
|
||||
Continuar = nom.SolicitudesNominasAdd(idSolicitudCFDI, idSolicitudMetadata, estatus, observaciones, fechaInicio, fechaFin, cveUsuarioIng, cveEmpresa);
|
||||
var api = new GeneralesAPI();
|
||||
api.GeneraSolicitud();
|
||||
api.VerificaSolicitudesNominas();
|
||||
}
|
||||
if (Continuar)
|
||||
{
|
||||
@@ -207,4 +218,198 @@ public partial class SAT_SolicitudesNominaSat : ClsPaginas
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class GeneralesAPI : ADSNetLibrary.Helpers.Conexiones.SIGAPI.BaseSIGAPI
|
||||
{
|
||||
public GeneralesAPI(string domainApi = "http://localhost:4001/", string token = "") : base(domainApi, token) { }
|
||||
|
||||
|
||||
public object GeneraSolicitud()
|
||||
{
|
||||
return getData<object>("GeneraSolicitud", null, ADSNetLibrary.Helpers.Conexiones.SIGAPI.requestMethod.GET,false);
|
||||
}
|
||||
public object VerificaSolicitudesNominas()
|
||||
{
|
||||
return getData<object>("VerificaSolicitudesNominas", null, ADSNetLibrary.Helpers.Conexiones.SIGAPI.requestMethod.GET, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//using ADSNetLibrary. SIGAPI;
|
||||
//using ADSNetLibrary. SIGAPI.Models;
|
||||
//using ADSNetLibrary. SIGAPI.Models.Request;
|
||||
//using ADSNetLibrary.SIGAPI.Models.Sistema;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
////using System.IdentityModel.Tokens.Jwt;
|
||||
//using System.Linq;
|
||||
//using System.Net.Http;
|
||||
//using System.Net.Http.Headers;
|
||||
//using System.Text;
|
||||
//using System.Threading;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
namespace ADSNetLibraryzd.Helpers.Conexiones.SIGAPI
|
||||
{
|
||||
|
||||
public enum requestMethod
|
||||
{
|
||||
POST = 1,
|
||||
GET = 2
|
||||
}
|
||||
public class BaseSIGAPI
|
||||
{
|
||||
private const string tituloLog = "ADSNetLibrary.Helpers.Conexiones.SIGAPI";
|
||||
public string domainApi;
|
||||
public string authorization;
|
||||
protected string RouteController = "";
|
||||
protected string FullRoute = "";
|
||||
public string GetRoutbyclass() { string classname = this.GetType().Name; return classname.Substring(0, classname.Length - 3); }
|
||||
public string GetRoute(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(FullRoute))
|
||||
{
|
||||
return string.Format("api/{0}/{1}", (string.IsNullOrEmpty(RouteController) ? GetRoutbyclass() : RouteController), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format("{0}{1}", FullRoute, path);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// nueva instancia de conexion para una api
|
||||
/// </summary>
|
||||
/// <param name="domainApi"> url de la api</param>
|
||||
/// <param name="authorization"> llenar si se tiene si se desea obtner usuar campos usuario y pasword</param>
|
||||
public BaseSIGAPI(string domainApi, string authorization = null, string fullRoute = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(domainApi))
|
||||
{
|
||||
domainApi = "http://localhost:4001/";//"http://jam.adssistemas.mx:4001/";//Helpers.ModVars.UrlApi;
|
||||
}
|
||||
this.authorization = authorization;
|
||||
this.domainApi = domainApi;
|
||||
this.FullRoute = fullRoute;
|
||||
}
|
||||
|
||||
//public string GetSIGToken(string userName, string password, int cveEmpresa)
|
||||
//{
|
||||
// var objauth = new RequestLogin() { UserName = userName, Password = password, CveEmpresa = cveEmpresa };
|
||||
// var retorno = getData<ResponseModel<ResponseLogin>>("api/Usuario/Login", objauth, requestMethod.POST, false, true);
|
||||
// if (retorno != null && retorno.IsSuccess)
|
||||
// {
|
||||
// return retorno.Result.AccessToken;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Obtiene datos de la api asincrono.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Clase genérica en donde se obtiene la información del SqlDataReader.</typeparam>
|
||||
/// <param name="path">ruta sin domino ejemplo "/api/usuarios/login".</param>
|
||||
/// <param name="requestobject">request object.</param>
|
||||
/// <returns>Lista de objetos.</returns>
|
||||
public async Task<T> getDataAsync<T>(string path, object requestobject, requestMethod reqmet = requestMethod.POST, bool needauthorization = true, bool isfullpath = false) where T : class, new()
|
||||
{
|
||||
T objreturn = null;
|
||||
using (
|
||||
HttpClient client = new HttpClient())
|
||||
{
|
||||
// Setting Base address.
|
||||
client.BaseAddress = new Uri(domainApi);
|
||||
// Setting content type.
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
// Setting Authorization.
|
||||
if (needauthorization) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authorization); }
|
||||
client.Timeout = TimeSpan.FromMinutes(15);
|
||||
HttpResponseMessage response = new HttpResponseMessage();
|
||||
|
||||
var strjsonreq = Newtonsoft.Json.JsonConvert.SerializeObject(requestobject);
|
||||
StringContent content = new StringContent(strjsonreq, Encoding.UTF8, "application/json");
|
||||
string route = isfullpath ? path : GetRoute(path);
|
||||
try
|
||||
{
|
||||
|
||||
switch (reqmet)
|
||||
{
|
||||
case requestMethod.POST:
|
||||
response = await client.PostAsync(route, content);
|
||||
break;
|
||||
case requestMethod.GET:
|
||||
response = await client.GetAsync(route);
|
||||
break;
|
||||
}
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string jsondata = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
Newtonsoft.Json.JsonSerializerSettings settings = new Newtonsoft.Json.JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
|
||||
MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore
|
||||
};
|
||||
objreturn = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(jsondata, settings);
|
||||
}
|
||||
else {
|
||||
//ModExtensiones.GuardaLog(string.Format("{0}{1}{2}{1}StatusCode:{3}{1}{4}{1}{5}{1}", tituloLog, ModVars.NewLine, route, response.StatusCode, response.RequestMessage, strjsonreq), ModVars.ADSNetLibraryLog);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
//ModExtensiones.GuardaLog(string.Format("{0}{1}{2}{1}{3}{1}{4}{1}", tituloLog, ModVars.NewLine, route, e, strjsonreq), ModVars.ADSNetLibraryLog);
|
||||
}
|
||||
|
||||
}
|
||||
return objreturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obtiene datos de la api.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Clase genérica en donde se obtiene la información del SqlDataReader.</typeparam>
|
||||
/// <param name="path">ruta sin domino ejemplo "/api/usuarios/login".</param>
|
||||
/// <param name="requestobject">request object.</param>
|
||||
/// <returns>Lista de objetos.</returns>
|
||||
public T getData<T>(string path, object requestobject, requestMethod reqmet = requestMethod.POST, bool needauthorization = true, bool isfullpath = false) where T : class, new()
|
||||
{
|
||||
return AsyncHelper.RunSync<T>(() => getDataAsync<T>(path, requestobject, reqmet, needauthorization, isfullpath));
|
||||
}
|
||||
}
|
||||
internal static class AsyncHelper
|
||||
{
|
||||
private static readonly TaskFactory _myTaskFactory = new
|
||||
TaskFactory(CancellationToken.None,
|
||||
TaskCreationOptions.None,
|
||||
TaskContinuationOptions.None,
|
||||
TaskScheduler.Default);
|
||||
|
||||
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
|
||||
{
|
||||
return AsyncHelper._myTaskFactory
|
||||
.StartNew<Task<TResult>>(func)
|
||||
.Unwrap<TResult>()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
public static void RunSync(Func<Task> func)
|
||||
{
|
||||
AsyncHelper._myTaskFactory
|
||||
.StartNew<Task>(func)
|
||||
.Unwrap()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user