I have the following function which receives the path of an Excel file to open it and read it to add users, I execute it in my project from Visual Studio and it runs without problems, when I take it to the server where it should work it shows me the error that I show, I was looking for and I did not find any reserved words that I could be using, because the database management I do it through LINQ Any idea?
public static string AgregarUsuarios(string DocExcel)
{
try
{
string path = ConfigurationManager.AppSettings["RutaBuscar"] + DocExcel;
SECDataContext SEC = new SECDataContext();
string respuesta = "";
ExcelQueryFactory Librito = new ExcelQueryFactory(path);
var resultado = (from datito in Librito.Worksheet("Hoja1")
let elmeeeeent = new EntidadHojaExcel
{
NumeroEmpleadoXX = datito["Numero"],
PuestoXX = datito["Puesto"],
UnidadXX = datito["Unidad"],
FechaIngresoXX = datito["FechaIn"],
NombreXX = datito["Nombre"]
}
select elmeeeeent).ToList();
if (resultado.Count > 0)
{
int VNE;
int UA = 0, UNA = 0, UE = 0;
foreach (EntidadHojaExcel D in resultado)
{
if (D.NumeroEmpleadoXX == "" || D.NumeroEmpleadoXX == null)
{
UNA++;
}
else
{
VNE = ValidaNumeroEmpleado(Convert.ToInt32(D.NumeroEmpleadoXX));
if (VNE > 0)
{
Puesto Puesto = (from p in SEC.Puesto where p.NombreP.Replace(" ","").ToLower() == D.PuestoXX.Replace(" ","").ToLower() select p).SingleOrDefault();
Unidad Unidad = (from u in SEC.Unidad where u.NombreUN.Replace(" ","") == D.UnidadXX.Replace(" ","") select u).SingleOrDefault();
Usuario U = new Usuario
{
IDP = Puesto.IDP,
IDR = 1,
IDUN = Unidad.IDUN,
NumeroEmpleadoU = Convert.ToInt32(D.NumeroEmpleadoXX),
NombreU = D.NombreXX,
EstatusU = true,
FechaIngresoU = Convert.ToDateTime(D.FechaIngresoXX)
};
SEC.Usuario.InsertOnSubmit(U);
SEC.SubmitChanges();
UA++;
}
else
{
UE++;
}
}
}
respuesta = "Usuarios Agregados: " + UA + " Usuarios No Agregados(Sin número de empleado): " + UNA + " Usuarios Existentes: " + UE;
}
return respuesta;
}
catch (Exception e)
{
string path = ConfigurationManager.AppSettings["RutaBuscar"] + DocExcel;
Log(e.Message + "AgregarUsuarios " + path);
return "Error";
}
}
IErrorInfo.GetDescription error with E_FAIL (0x80004005)