Ejemplo n.º 1
0
        public JsonResult SetParamCapture(int idYear, int idMonth, int idSoupK, string soupK, string year, string month, string pFolio, string pCode)
        {
            SedesolServiceClient proxy   = new SedesolServiceClient();
            CaptureModel         cModel  = new CaptureModel();
            CaptureDTO           captDto = new CaptureDTO();
            AttendanceDTO        attDto  = new AttendanceDTO();
            UserDTO userDto = (UserDTO)Session["userData"];
            string  message = string.Empty;

            captDto.Id_Month         = idMonth;
            captDto.Id_Year          = idYear;
            captDto.Id_Soup_Kitchen  = idSoupK;
            captDto.CreateDate       = DateTime.Now;
            captDto.Description      = year + " | " + month + " | " + soupK;
            captDto.IsActive         = true;
            captDto.Id_Status        = Convert.ToInt32(ConfigurationManager.AppSettings["stIniciada"].ToString());
            captDto.Folio            = pFolio;
            captDto.InspectionCode   = pCode;
            captDto.Id_LevelApproval = userDto.UserType.Id;
            captDto.Id_User          = userDto.Id;
            cModel.Capture           = proxy.SaveCapture(captDto);

            //cModel.Capture = captDto;
            cModel.Attendance = attDto;

            Session.Add("CaptureModel", cModel);

            return(Json(new { message = cModel.Capture.Message }));
        }
Ejemplo n.º 2
0
        private async void TmonitorCaptureElapsedAsync(object sender, ElapsedEventArgs e)
        {
            try
            {
                var Cfrecuency = (DateTime.Now - LastUCaptureupload).TotalSeconds;
                if (CaptureFrecuency < Cfrecuency)
                {
                    LastUCaptureupload = DateTime.Now;
                    /**capturando un print screen de la pantalla activa*/
                    if (!sendingcapture)
                    {
                        sendingcapture = true;
                        CaptureModel Capture = new CaptureModel();
                        Capture = CaptureWind();

                        Response rep = new Response();
                        rep = await CallApiCapture("Capture/WindowsCapture", Capture, token);

                        sendingcapture = false;
                    }
                }
            }
            catch (Exception ex)
            {
                writelog(ex.Message, "Error TmonitorCaptureElapsed()");
            }
        }
Ejemplo n.º 3
0
        public JsonResult DeleteFile(int idFile)
        {
            var    client = new SedesolService.SedesolServiceClient();
            string data   = client.DeleteCaptureImage(idFile);

            CaptureModel           captureModel = (CaptureModel)Session["CaptureModel"];
            List <CaptureImageDTO> listImage    = new List <CaptureImageDTO>();

            listImage = client.GetImageByCaptureId(captureModel.Capture.Id);
            foreach (CaptureImageDTO item in listImage)
            {
                item.ImageFileB64 = "data:image/jpeg; base64," + Convert.ToBase64String(item.ImageFile);
            }

            Session["CountImg"] = null;
            Session.Add("CountImg", listImage.Count());

            client.Close();

            string viewContent = ConvertViewToString("ImageList", listImage);
            var    sjonResult  = Json(new { message = data, PartialView = viewContent });

            sjonResult.MaxJsonLength = int.MaxValue;

            return(sjonResult);
        }
Ejemplo n.º 4
0
        public ActionResult CaptureAttendance(int id = 0)
        {
            SedesolServiceClient proxy = new SedesolServiceClient();
            CaptureModel         model = new CaptureModel();
            int countImg = 0;

            if (id != null && id > 0)
            {
                CaptureDTO capture = proxy.GetCaptureById(id);
                foreach (CaptureImageDTO item in capture.ImageList)
                {
                    item.ImageFileB64 = "data:image/jpeg; base64," + Convert.ToBase64String(item.ImageFile);
                }
                countImg               = capture.ImageList.Count();
                model.Capture          = capture;
                model.StateDtoList     = proxy.GetActiveStates();
                model.ConditionDtoList = proxy.GetActiveCondition();

                //CaptureModel cModel = new CaptureModel();
                //cModel.Capture = capture;
                Session.Add("CountImg", countImg);
                Session.Add("CaptureModel", model);
            }
            else
            {
                model = (CaptureModel)Session["CaptureModel"];
                model.StateDtoList     = proxy.GetActiveStates();
                model.ConditionDtoList = proxy.GetActiveCondition();
            }

            return(View(model));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Default Constructor with width = 320 and height = 240
 /// </summary>
 /// <param name="selectedCameraIndex">Set the selected camera index</param>
 public EyeWebcam(int selectedCameraIndex)
 {
     this._webcamIndex = selectedCameraIndex;
     this._captureModel = CaptureModel.Instance;
     this._width = 320;
     this._height = 240;
     this._image = new Bitmap(320,240);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor with width and height
 /// </summary>
 /// <param name="width">Set the width for capturing</param>
 /// <param name="height">Set the height for capturing</param>
 /// <param name="selectedCameraIndex">Set the selected camera index</param>
 public EyeWebcam(int width, int height, int selectedCameraIndex)
 {
     this._webcamIndex = selectedCameraIndex;
     this._captureModel = CaptureModel.Instance;
     this._width = width;
     this._height = height;
     _image = new Bitmap(width, height);
 }
Ejemplo n.º 7
0
 public Brain(int handCutX1, int handCutY1, int handCutX2, int handCutY2)
 {
     this.handCutX1 = handCutX1;
     this.handCutX2 = handCutX2;
     this.handCutY1 = handCutY1;
     this.handCutY2 = handCutY2;
     this._captureModel = CaptureModel.Instance;
     this._capturedImageChanged = false;
     this.algorithmRunning = false;
     this._result = -1;
 }
Ejemplo n.º 8
0
        public IActionResult Register()
        {
            RegisterModel rm = new RegisterModel();
            CaptureModel  cm = new CaptureModel();

            cm.code       = rm.code;
            cm.hashstring = rm.CaptureHash;
            if (db.CaptureModels.Find(cm.hashstring) == null)
            {
                db.CaptureModels.Add(cm);
                db.SaveChanges();
            }
            return(View(rm));
        }
Ejemplo n.º 9
0
        public FileContentResult GetCapturePicture(string hash)
        {
            CaptureModel cm = db.CaptureModels.Find(hash);

            if (cm == null)
            {
                return(null);
            }

            CaptchaImage img = new CaptchaImage(cm.code, 120, 50);
            MemoryStream ms  = new MemoryStream();

            img.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            return(new FileContentResult(ms.GetBuffer(), "image/jpeg"));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Capture(CaptureModel model)
        {
            if (ModelState.IsValid)
            {
                using var memoryStream = new MemoryStream();
                await model.ImageToAnalyze.CopyToAsync(memoryStream);

                string imageId = await SendImageToStorage(memoryStream.ToArray()).ConfigureAwait(false);

                imageId = imageId.Replace("\"", "");

                ViewData["ImageName"] = imageId;
                return(View("Result"));
            }

            return(BadRequest());
        }
Ejemplo n.º 11
0
        public JsonResult DeleteAttendance(int idAttendance)
        {
            CaptureModel captureModel = (CaptureModel)Session["CaptureModel"];

            SedesolServiceClient proxy = new SedesolServiceClient();
            string data = proxy.DeleteAttendance(idAttendance);

            var ItemRemove = captureModel.Capture.AttendanceList.Single(r => r.Id == idAttendance);

            captureModel.Capture.AttendanceList.Remove(ItemRemove);

            Session["CaptureModel"] = null;
            Session.Add("CaptureModel", captureModel);

            string viewContent = ConvertViewToString("AttendanceList", captureModel.Capture.AttendanceList);

            return(Json(new { message = data, PartialView = viewContent }));
        }
Ejemplo n.º 12
0
        public ActionResult GetModalAttendance(int id)
        {
            CaptureModel model = new CaptureModel();

            if (id != null && id > 0)
            {
                SedesolServiceClient proxy   = new SedesolServiceClient();
                CaptureDTO           capture = proxy.GetCaptureById(id);
                model.Capture = capture;
                CaptureModel cModel = new CaptureModel();

                cModel.Capture = capture;

                //Session.Add("CaptureModel", cModel);
            }
            else
            {
                model = (CaptureModel)Session["CaptureModel"];
            }
            return(PartialView("ModalAttendance", model));
        }
Ejemplo n.º 13
0
        private CaptureModel CaptureWind()
        {
            string       history  = "";
            CaptureModel Captures = new CaptureModel();

            try
            {
                //Creating a new Bitmap object
                Bitmap       captureBitmap    = new Bitmap(1024, 768, PixelFormat.Format32bppArgb);
                MemoryStream ms               = new MemoryStream();
                Rectangle    captureRectangle = Screen.AllScreens[0].Bounds;
                Graphics     captureGraphics  = Graphics.FromImage(captureBitmap);
                captureGraphics.CopyFromScreen(captureRectangle.Left, captureRectangle.Top, 0, 0, captureRectangle.Size);
                //Guid gname = Guid.NewGuid();
                //captureBitmap.Save("~\\Captures\\" + gname + ".jpg", ImageFormat.Jpeg);
                //captureBitmap.Save("D:\\Proyectos\\Personales\\Andres Villa Proyectos\\ADA\\Monitor\\MonitorTrackerForm\\monitortracker\\Captures\\" + gname + ".jpg", ImageFormat.Jpeg);
                captureBitmap.Save(ms, ImageFormat.Jpeg);
                captureBitmap.Dispose();
                history = history + "captura";
                byte[] byteImage = ms.ToArray();
                ms.Dispose();
                var SigBase64 = Convert.ToBase64String(byteImage); // Get Base64

                history = history + "base 64";

                Captures.token    = token;
                Captures.Image    = byteImage;
                Captures.Pc       = Environment.MachineName;
                Captures.UserName = Environment.UserName;
                Captures.Ip       = UserIp;

                history = history + "llamando api";
                return(Captures);
            }
            catch (Exception ex)
            {
                writelog(ex.Message + history, "Error CaptureWind()");
            }
            return(Captures);
        }
Ejemplo n.º 14
0
        //CREA CAPTURAS DE PANATALLA DE LOS USUARIOS
        public object CreateCapture(CaptureModel o)
        {
            Response rp = new Response();

            try
            {
                cp = tvh.getprincipal(Convert.ToString(o.token));
                if (cp != null)
                {
                    string      empresa = cp.Claims.Where(c => c.Type == ClaimTypes.GroupSid).Select(c => c.Value).SingleOrDefault();
                    CaptureBase cb      = new CaptureBase();
                    o.IdCompany = empresa;
                    Copier.CopyPropertiesTo(o, cb);
                    if (cb != null)
                    {
                        bool response = opc.AddCapture(cb);
                        if (response)
                        {
                            rp.response_code = GenericErrors.SaveOk.ToString();
                        }
                        else
                        {
                            rp = autil.ReturnMesagge(ref rp, (int)GenericErrors.GeneralError, string.Empty, null, HttpStatusCode.InternalServerError);
                        }

                        List <CaptureBase> getimage = opc.GeImage(empresa);
                    }
                }
            }
            catch (Exception ex)
            {
                //error general
                rp = autil.ReturnMesagge(ref rp, (int)GenericErrors.GeneralError, ex.Message + " " + ex.InnerException, null, HttpStatusCode.InternalServerError);
                return(rp);
            }
            return(rp);
        }
Ejemplo n.º 15
0
        public HttpResponseMessage WindowsCapture(CaptureModel t)
        {
            aAutomaticTakeTime s = new aAutomaticTakeTime();

            return(ut.ReturnResponse(s.CreateCapture(t)));
        }
Ejemplo n.º 16
0
        public ActionResult UploadFiles(string pFileCam, HttpPostedFileBase pFile, string pType)
        {
            string responseS           = string.Empty;
            SedesolServiceClient proxy = new SedesolServiceClient();
            string viewContent         = string.Empty;
            int    countImage          = Convert.ToInt32(Session["CountImg"].ToString());

            try
            {
                if (countImage < Convert.ToInt32(ConfigurationManager.AppSettings["maxCountFiles"].ToString()))
                {
                    if (pType == "1")
                    {
                        if (pFileCam != string.Empty)
                        {
                            string[]        ar           = pFileCam.Split(',');
                            CaptureModel    captureModel = (CaptureModel)Session["CaptureModel"];
                            CaptureImageDTO dto          = new CaptureImageDTO();

                            dto.Id_Capture   = captureModel.Capture.Id;
                            dto.FromCam      = false;
                            dto.ImageFile    = Convert.FromBase64String(ar[1]);
                            dto.ImageFileB64 = string.Empty;
                            dto.ImagePath    = string.Empty;
                            dto.Name         = "test";

                            int response = proxy.SaveCaptureImage(dto);
                            if (response > 0)
                            {
                                responseS = "SUCCESS";
                            }
                        }
                        else
                        {
                            responseS = "Debe activar la cámara y tomar la foto.";
                        }
                    }
                    else
                    {
                        //fileupload
                        if (Request.Files.Count > 0 && pFile != null)
                        {
                            if (pFile.ContentType == "image/jpeg")
                            {
                                if (pFile.ContentLength <= (1048576))
                                {
                                    string fname;
                                    //bool success = false;

                                    if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                                    {
                                        string[] testfiles = pFile.FileName.Split(new char[] { '\\' });
                                        fname = testfiles[testfiles.Length - 1];
                                    }
                                    else
                                    {
                                        fname = pFile.FileName;
                                    }

                                    BinaryReader binaryReader = new BinaryReader(pFile.InputStream);
                                    byte[]       binaryData   = binaryReader.ReadBytes((int)pFile.InputStream.Length);

                                    CaptureModel    captureModel = (CaptureModel)Session["CaptureModel"];
                                    CaptureImageDTO dto          = new CaptureImageDTO();

                                    dto.Id_Capture   = captureModel.Capture.Id;
                                    dto.FromCam      = false;
                                    dto.ImageFile    = binaryData;
                                    dto.ImageFileB64 = string.Empty;
                                    dto.ImagePath    = string.Empty;
                                    dto.Name         = fname;

                                    int response = proxy.SaveCaptureImage(dto);
                                    if (response > 0)
                                    {
                                        responseS = "SUCCESS";
                                    }
                                }
                                else
                                {
                                    responseS = "Tamaño máximo permitido: 1MB.";
                                }
                            }
                            else
                            {
                                responseS = "El archivo ingresado debe ser en formato jpg.";
                            }
                        }
                        else
                        {
                            responseS = "Debe seleccionar un archivo.";
                        }
                    }
                }
                else
                {
                    responseS = "Máximo de imágenes por captura: " + ConfigurationManager.AppSettings["maxCountFiles"].ToString();
                }
            }
            catch (Exception ex)
            {
                responseS = "Error al guardar archivo. Contacte al Administrador.";
            }
            finally
            {
                CaptureModel           captureModel = (CaptureModel)Session["CaptureModel"];
                List <CaptureImageDTO> listImage    = new List <CaptureImageDTO>();

                listImage           = proxy.GetImageByCaptureId(captureModel.Capture.Id);
                Session["CountImg"] = null;
                Session.Add("CountImg", listImage.Count());

                foreach (CaptureImageDTO item in listImage)
                {
                    item.ImageFileB64 = "data:image/jpeg; base64," + Convert.ToBase64String(item.ImageFile);
                }
                proxy.Close();
                viewContent = ConvertViewToString("ImageList", listImage);
            }
            var sjonResult = Json(new { message = responseS, PartialView = viewContent });

            sjonResult.MaxJsonLength = int.MaxValue;

            return(sjonResult);
        }
Ejemplo n.º 17
0
        public JsonResult CaptureAttendance(AttendanceDTO att)
        {
            try
            {
                CaptureModel captureModel = (CaptureModel)Session["CaptureModel"];

                att.Id_Capture = captureModel.Capture.Id;
                att.IsActive   = true;
                att.CreateDate = DateTime.Now;
                var oldId = att.Id;

                SedesolServiceClient proxy = new SedesolServiceClient();

                Session["CaptureModel"] = null;
                Session.Add("CaptureModel", captureModel);

                string curpValidation = string.Empty;

                if (!att.HasCurp || att.IsAnonym)
                {
                    curpValidation = "SUCCESS";
                }
                else
                {
                    //validate curp
                    curpValidation = ValidateCurp(att.Curp);
                }


                if (curpValidation == "SUCCESS")
                {
                    att = proxy.SaveAttendance(att);

                    if (att.Message == "SUCCESS")
                    {
                        captureModel.StatusMessage = "SUCCESS";
                        if (oldId > 0)
                        {
                            var ItemRemove = captureModel.Capture.AttendanceList.Single(r => r.Id == oldId);
                            captureModel.Capture.AttendanceList.Remove(ItemRemove);
                        }
                        captureModel.Capture.AttendanceList.Add(att);
                    }
                    else
                    {
                        captureModel.StatusMessage = "ERROR";
                    }
                }
                else
                {
                    captureModel.StatusMessage = "ERRORCURP";
                    //att.Message = "ERRORCURP";
                }

                string viewContent = ConvertViewToString("AttendanceList", captureModel.Capture.AttendanceList);
                return(Json(new { message = captureModel.StatusMessage, PartialView = viewContent, MessageError = curpValidation }));
            }
            catch (Exception ex)
            {
                return(Json(new { message = "ERROR" }));
            }
        }