Exemple #1
0
        public DataTable RetornarEmpleado()
        {
            DataTable dtbEmpleados = new DataTable();
            DataTable dtbAuditoria = new DataTable("Auditoria");

            ServicioProperTime.ServicioProperTimeClient objServicioProperTime;
            objServicioProperTime = new ServicioProperTime.ServicioProperTimeClient();
            int    intRandom = 1;
            Random rnd       = new Random();

            try
            {
                objServicioProperTime.Open();
                dtbEmpleados = objServicioProperTime.RetornaEmpleados("1=1").Tables[0];
                dtbEmpleados.Columns.Add(Constantes.ColumnaDatoEmpleadoPHOTOB, typeof(byte[]));
                foreach (DataRow dtr in dtbEmpleados.Rows)
                {
                    intRandom = rnd.Next(1, 5);
                    string sTemp = HttpContext.Current.Server.MapPath("/Imagenes/empleado" + intRandom + ".jpg");
#pragma warning disable SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}'
#pragma warning disable IDE0017 // Simplify object initialization
                    FileStream fs = new FileStream(sTemp, FileMode.OpenOrCreate, FileAccess.ReadWrite);
#pragma warning restore IDE0017 // Simplify object initialization
#pragma warning restore SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}'
                    //img.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
                    fs.Position = 0;

                    int    imgLength = Convert.ToInt32(fs.Length);
                    byte[] bytes     = new byte[imgLength];
                    dtr[Constantes.ColumnaDatoEmpleadoPHOTOB] = bytes;
                    fs.Read(bytes, 0, imgLength);
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally {
                if (objServicioProperTime != null && objServicioProperTime.State == System.ServiceModel.CommunicationState.Opened)
                {
                    objServicioProperTime.Close();
                }
            }
            return(dtbEmpleados);
        }
Exemple #2
0
        public DataTable RetornarEmpleadoAdministrador()
        {
            DataTable dtbEmpleados = new DataTable();
            DataTable dtbAuditoria = new DataTable("Auditoria");

            ServicioProperTime.ServicioProperTimeClient objServicioProperTime;
            objServicioProperTime = new ServicioProperTime.ServicioProperTimeClient();
            int    intRandom = 1;
            Random rnd       = new Random();

            try
            {
                objServicioProperTime.Open();
                dtbEmpleados = objServicioProperTime.RetornaEmpleados("1=1").Tables[0];
                dtbEmpleados.Columns.Add(Constantes.ColumnaDatoEmpleadoPHOTOB, typeof(byte[]));
                foreach (DataRow dtr in dtbEmpleados.Rows)
                {
                    if (Convert.ToInt32(dtr[Constantes.ColumnaEmpleadoOTAdmin]) == 0)
                    {
                        dtr.Delete();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (objServicioProperTime != null && objServicioProperTime.State == System.ServiceModel.CommunicationState.Opened)
                {
                    objServicioProperTime.Close();
                }
            }
            return(dtbEmpleados);
        }