420 lines
No EOL
13 KiB
C#
420 lines
No EOL
13 KiB
C#
using Newtonsoft.Json;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.Web;
|
|
using System.Web.Configuration;
|
|
using System.Web.Mvc;
|
|
using ULA.Davivienda.ModuloReportes.Commons;
|
|
using Ultimus.Interfaces;
|
|
using Ultimus.Interfaces.UltimusForm;
|
|
using Ultimus.Utilitarios;
|
|
|
|
namespace ULA.Davivienda.ModuloReportes.Controllers
|
|
{
|
|
public class BaseController : Controller
|
|
{
|
|
|
|
UltimusLogs UltimusLogs = new UltimusLogs("BaseController");
|
|
|
|
private string _IDLogger;
|
|
|
|
public string IDLogger
|
|
{
|
|
get { return _IDLogger; }
|
|
set { _IDLogger = string.Format("INCIDENT {0}|", value); }
|
|
}
|
|
|
|
public string UserID
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["UserID"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["UserID"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string TaskID
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["TaskID"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["TaskID"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string Process
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["Process"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["Process"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string Step
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["Step"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["Step"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string Incident
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["Incident"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["Incident"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string JobFunction
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["JobFunction"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["JobFunction"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string UserFullName
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["UserFullName"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["UserFullName"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string UserEmail
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["UserEmail"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["UserEmail"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string Supervisor
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["Supervisor"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["Supervisor"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string SupervisorFullName
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["SupervisorFullName"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["SupervisorFullName"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string TaskStatus
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["TaskStatus"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["TaskStatus"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string Version
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["Version"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["Version"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string sol_codigo_temp
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["sol_codigo_temp"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["sol_codigo_temp"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string sol_co_solicitud
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["sol_co_solicitud"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["sol_co_solicitud"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public string sol_co_cliente_principal
|
|
{
|
|
get
|
|
{
|
|
string ret = string.Empty;
|
|
if (!string.IsNullOrEmpty(Request.QueryString["sol_co_cliente_principal"]))
|
|
ret = new Crypt().DecryptString(Request.QueryString["sol_co_cliente_principal"]);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public Ultimus.Interfaces.UltimusIntegration.UltimusIncident Tarea
|
|
{
|
|
get
|
|
{
|
|
if (Session["Tarea"] == null)
|
|
|
|
return null;
|
|
else
|
|
return Session["Tarea"] as Ultimus.Interfaces.UltimusIntegration.UltimusIncident;
|
|
}
|
|
set
|
|
{
|
|
Session["Tarea"] = value;
|
|
}
|
|
}
|
|
|
|
public void LeerTarea()
|
|
{
|
|
|
|
if (Request.Cookies["UserID"] != null && Request.Cookies["TaskID"] != null)
|
|
{
|
|
Tarea = new UltimusManager().GetTask(Request.Cookies["UserID"].Value, Request.Cookies["TaskID"].Value);
|
|
BorrarCookie("UserID");
|
|
BorrarCookie("TaskID");
|
|
|
|
try
|
|
{
|
|
|
|
string TareaJson = JsonConvert.SerializeObject(Tarea);
|
|
|
|
UltimusLogs.Trace("SerializeObject TareaJson=" + TareaJson);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
UltimusLogs.Trace("Error TareaJson=" + ex.ToString());
|
|
|
|
}
|
|
|
|
if (Tarea == null)
|
|
{
|
|
|
|
throw new Exception("TaskID or UserID is null____" + Request.Cookies["UserID"].Value + "____" + Request.Cookies["TaskID"].Value);
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("TaskID or UserID is null");
|
|
}
|
|
|
|
}
|
|
|
|
public ActionResult ErrorGenerico
|
|
{
|
|
get { return View("Error"); }
|
|
}
|
|
|
|
private void BorrarCookie(string cookie)
|
|
{
|
|
HttpCookie myCookie = Request.Cookies.Get(cookie);
|
|
if (myCookie != null)
|
|
{
|
|
Request.Cookies.Remove(myCookie.Name);
|
|
myCookie.Expires = DateTime.Now.AddMonths(-1);
|
|
Response.Cookies.Add(myCookie);
|
|
}
|
|
}
|
|
|
|
public RedirectResult RedirectEncrypted(string url)
|
|
{
|
|
Crypt crypt = new Crypt();
|
|
return Redirect(string.Format("{0}?UserID={1}&TaskID={2}&Process={3}&Step={4}&Incident={5}", url, UserID, TaskID, Process, Step, Incident));
|
|
}
|
|
|
|
public RedirectToRouteResult RedirectToActionEncrypted(string ation, string controller)
|
|
{
|
|
Crypt crypt = new Crypt();
|
|
return RedirectToAction(ation, controller, new { UserID = crypt.EncryptString(UserID), TaskID = crypt.EncryptString(TaskID), Process = crypt.EncryptString(Process), Step = crypt.EncryptString(Step), Incident = crypt.EncryptString(Incident) });
|
|
}
|
|
|
|
public void InitControllers()
|
|
{
|
|
|
|
ViewBag.IpAdress = Commons.Utilities.GetIpAdress();
|
|
ViewBag.MachineName = Dns.GetHostName();
|
|
ViewBag.ActivityType = "WORKFLOW";
|
|
ViewBag.HostResponse = Commons.Utilities.GetIpAdress();
|
|
|
|
ViewBag.Incident = Incident;
|
|
|
|
ViewBag.UserID = UserID;
|
|
ViewBag.TaskId = TaskID;
|
|
ViewBag.Process = Process;
|
|
ViewBag.Step = Step;
|
|
ViewBag.TaskStatus = TaskStatus;
|
|
|
|
ViewBag.JobFunction = JobFunction;
|
|
ViewBag.UserFullName = UserFullName;
|
|
ViewBag.UserEmail = UserEmail;
|
|
ViewBag.Supervisor = Supervisor;
|
|
ViewBag.SupervisorFullName = SupervisorFullName;
|
|
ViewBag.Version = Version;
|
|
|
|
#region Variables of process
|
|
|
|
if (Request.QueryString["sol_co_solicitud"] != null)
|
|
ViewBag.sol_co_solicitud = Request.QueryString["sol_co_solicitud"].ToString();
|
|
else
|
|
ViewBag.sol_co_solicitud = 0;
|
|
|
|
if (Request.QueryString["cl_co_cliente"] != null)
|
|
ViewBag.cl_co_cliente = Request.QueryString["cl_co_cliente"].ToString();
|
|
else
|
|
ViewBag.cl_co_cliente = 0;
|
|
|
|
if (Request.QueryString["co_adicional"] != null)
|
|
ViewBag.co_adicional = Request.QueryString["co_adicional"].ToString();
|
|
else
|
|
ViewBag.co_adicional = 0;
|
|
|
|
|
|
if (Process == Resources.General.ProcesoClienteCentrico)
|
|
{
|
|
ViewBag.CodProcess = Resources.General.PRO_ClienteCentrico;
|
|
}
|
|
else if (Process == Resources.General.ProcesoTDC)
|
|
{
|
|
ViewBag.CodProcess = Resources.General.PRO_Prestamo_TDC;
|
|
}
|
|
|
|
#endregion
|
|
|
|
ViewBag.Pipe = "|";
|
|
|
|
try
|
|
{
|
|
Boolean vLocal = false;
|
|
|
|
Boolean.TryParse(WebConfigurationManager.AppSettings["ComplementBPM.local"].ToString(), out vLocal);
|
|
|
|
if (vLocal)
|
|
{
|
|
|
|
StepFormsList[] Menulist = new StepFormsList[1];
|
|
|
|
Menulist[0] = new StepFormsList { FormName = "OFFLINE" };
|
|
|
|
ViewBag.Menu = Menulist;
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
if (Process != string.Empty && Step != string.Empty)
|
|
{
|
|
|
|
List<StepFormsList> Menulist = new MenuManager().ObtenerFormularios(Process, Step);
|
|
|
|
ViewBag.Menu = Menulist;
|
|
|
|
}
|
|
else
|
|
{
|
|
StepFormsList[] Menulist = new StepFormsList[1];
|
|
|
|
Menulist[0] = new StepFormsList { FormName = "OFFLINE" };
|
|
|
|
ViewBag.Menu = Menulist;
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
UltimusLogs.Error(ex.ToString());
|
|
|
|
StepFormsList[] Menulist = new StepFormsList[1];
|
|
|
|
Menulist[0] = new StepFormsList { FormName = "OFFLINE" };
|
|
|
|
ViewBag.Menu = Menulist;
|
|
}
|
|
|
|
string QueryString = "?";
|
|
|
|
QueryString = string.Concat(QueryString, "UserID={0}");
|
|
QueryString = string.Concat(QueryString, "&TaskID={1}");
|
|
QueryString = string.Concat(QueryString, "&Process={2}");
|
|
QueryString = string.Concat(QueryString, "&Step={3}");
|
|
QueryString = string.Concat(QueryString, "&Incident={4}");
|
|
QueryString = string.Concat(QueryString, "&JobFunction={5}");
|
|
QueryString = string.Concat(QueryString, "&UserFullName={6}");
|
|
QueryString = string.Concat(QueryString, "&UserEmail={7}");
|
|
QueryString = string.Concat(QueryString, "&Supervisor={8}");
|
|
QueryString = string.Concat(QueryString, "&SupervisorFullName={9}");
|
|
QueryString = string.Concat(QueryString, "&TaskStatus={10}");
|
|
QueryString = string.Concat(QueryString, "&Version={11}");
|
|
|
|
ViewBag.QueryEncripted = string.Format(QueryString,
|
|
Request.QueryString["UserID"],
|
|
Request.QueryString["TaskID"],
|
|
Request.QueryString["Process"],
|
|
Request.QueryString["Step"],
|
|
Request.QueryString["Incident"],
|
|
Request.QueryString["JobFunction"],
|
|
Request.QueryString["UserFullName"],
|
|
Request.QueryString["UserEmail"],
|
|
Request.QueryString["Supervisor"],
|
|
Request.QueryString["SupervisorFullName"],
|
|
Request.QueryString["TaskStatus"],
|
|
Request.QueryString["Version"]);
|
|
|
|
#region Variables of process
|
|
|
|
if (Request.QueryString["sol_co_solicitud"] != null)
|
|
ViewBag.QueryEncripted = string.Concat(ViewBag.QueryEncripted, "&sol_co_solicitud=", ViewBag.sol_co_solicitud);
|
|
|
|
#endregion
|
|
|
|
UltimusLogs.Trace("ViewBag.QueryEncripted=" + ViewBag.QueryEncripted);
|
|
}
|
|
|
|
}
|
|
} |