예제 #1
0
        public IActionResult SalvarRegistro(Registro r)
        {
            RegistroRepository repositorio = new RegistroRepository();

            repositorio.Cadastra(r);



            return(RedirectToAction("Index"));
        }
예제 #2
0
        public IActionResult Login(Registro r)
        {
            RegistroRepository rr       = new RegistroRepository();
            Registro           registro = rr.QueryLogin(r);

            if (registro != null)
            {
                ViewBag.Mensagem = "Você está logado";

                HttpContext.Session.SetString("EMail", registro.EMail);

                return(Redirect("Index"));
            }
            else
            {
                ViewBag.Mensagem = "Falha no Login";

                return(View());
            }
        }
 public RegistroController()
 {
     this.RegistroRepository = new RegistroRepository();
 }
예제 #4
0
 public RegistroService(RegistroRepository repository, TagRepository tagRepository)
 {
     this.repository    = repository;
     this.tagRepository = tagRepository;
 }
        public AppRolResultModel Serialize()
        {
            AppRolResultModel send = new AppRolResultModel();
            string webMethodName = "Upload_AppRol";
            try
            {

                //send.UploadAppRolResult = GetIsModified();
                var client = new RestClient(SyncProperties.routeUpload);
                //client.Authenticator = new HttpBasicAuthenticator(basicAuthUser, basicAuthPass);
                var request = new RestRequest(Method.POST);
                request.Resource = webMethodName;
                request.RequestFormat = RestSharp.DataFormat.Json;
                request.AddHeader("Content-type", "application/json");
                //Body
                MaxTableModel maximos = new MaxTableModel();
                IRestResponse response = null;
                RegistroRepository registroRepository = new RegistroRepository();
                request.AddBody(new
                {
                    param = send
                });
                response = client.Execute(request);
                string res = response.Content;
            }
            catch (Exception)
            {

            }
            return send;
        }
        public bool DownloadOnDemand(long lastDate, long IdPuntoMedicion)
        {
            bool x = false;
            string webMethodName = "Download_CIRegistroOnDemand";
            CiRegistroOnDemandResultModel list = new CiRegistroOnDemandResultModel();
            RegistroRepository registroRepository = new RegistroRepository();
            BodyContentOnDemand bodyContent = null;
            try
            {
                bodyContent = GetBodyOnDemand(lastDate, IdPuntoMedicion);
                //Desearilizar la respuestas
                string jsonResponse = DownloadFactory.Instance.CallWebService(webMethodName, bodyContent);
                JavaScriptSerializer js = new JavaScriptSerializer();
                js.MaxJsonLength = Int32.MaxValue;
                list = js.Deserialize<CiRegistroOnDemandResultModel>(jsonResponse);
                if(list.Download_CIRegistroOnDemandResult!=null && list.Download_CIRegistroOnDemandResult.Count>0)
                {
                    x = UpsertOnDemand(list.Download_CIRegistroOnDemandResult);
                }
            }
            catch (Exception ex)
            {
                AppBitacoraRepository.Insert(new AppBitacoraModel() { Fecha = DateTime.Now, Metodo = ex.StackTrace, Mensaje = ex.Message });
            }

            return x;
        }
        /// <summary>
        /// Logica de descarga e inserción de registros de servidor en base local
        /// </summary>
        /// <returns></returns>
        public bool Download()
        {
            bool responseService = false;

            string webMethodName = "Download_CIRegistroRecurrent";
            CiRegistroRecurrentResultModel list = new CiRegistroRecurrentResultModel();
            RegistroRepository registroRepository = new RegistroRepository();
            long requestedFechaFin = 0;
            long minFechaNumerica = 0;

            try
            {
                //Obtener parámetros que se pasarán al servicio
                RequestBodyContent bodyContent = this.GetBodyContent();
                SQLLogger.Instance.log("BodyContent",bodyContent.ToString() );
                requestedFechaFin = bodyContent.fechaFin;
                minFechaNumerica = requestedFechaFin;

                //Preparacion para bulk upsert
                this.PrepareRecurrentBulkUpsert();
                SQLLogger.Instance.log("PrepareBulk","Paso" );
                while (requestedFechaFin <= minFechaNumerica)
                {
                    //Desearilizar la respuestas
                    string jsonResponse = DownloadFactory.Instance.CallWebService(webMethodName, bodyContent);
                    SQLLogger.Instance.log("JsonResponse", jsonResponse);
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    js.MaxJsonLength = Int32.MaxValue;
                    list = js.Deserialize<CiRegistroRecurrentResultModel>(jsonResponse);
                    SQLLogger.Instance.log("DeserealizaJson","Paso" );
                    //Obtener la fecha mas antigua de los datos recibidos
                    if (list.Download_CIRegistroRecurrentResult != null && list.Download_CIRegistroRecurrentResult.Count > 0)
                    {
                        //Insertar datos del servidor
                        this.BulkUpsertRecurrent(list.Download_CIRegistroRecurrentResult);
                        SQLLogger.Instance.log("BulkUpsert", "Paso");
                        minFechaNumerica = Int64.Parse(list.Download_CIRegistroRecurrentResult.Min(p => p.FechaNumerica).ToString().Substring(0, 8));
                        SQLLogger.Instance.log("FechaNuericaActual", "Paso");
                        //Restar un día a la fecha minima
                        if (minFechaNumerica.ToString().Length == 8)
                        {
                            DateTime dt = new DateTime(Int32.Parse(minFechaNumerica.ToString().Substring(0, 4)), Int32.Parse(minFechaNumerica.ToString().Substring(4, 2)), Int32.Parse(minFechaNumerica.ToString().Substring(6, 2)));
                            dt = dt.AddDays(-1);
                            SQLLogger.Instance.log("RestarDia", "Paso");
                            minFechaNumerica = Int64.Parse(String.Format("{0:yyyyMMdd}", dt));
                            bodyContent = this.GetBodyContent();
                            bodyContent.fechaActual = minFechaNumerica;
                        }
                        else
                        {
                            minFechaNumerica = 0;
                        }
                    }
                    else
                    {
                        minFechaNumerica = 0;
                    }
                }

                bool DataChanged = this.CommitBulkUpsertRecurrent();
                SQLLogger.Instance.log("Commit", DataChanged.ToString());
                if (DataChanged)
                {
                    this.RaiseDidCiRegistroRecurrentDataChanged(DataChanged);
                }

                responseService = true;
            }
            catch (Exception ex)
            {
                //InsertLog(ex.Source.ToString(), ex.Message);
                //Implementar bitácora
                //throw ex;
                SQLLogger.Instance.log("TryDownload", ex.Message);
            }

            return responseService;
        }
예제 #8
0
 public RegistroBusiness()
 {
     this.repositorio = new RegistroRepository();
 }