Exemple #1
0
        private void CrearTarifasBase(string empresa)
        {
            var newContext = new ContextLogin()
            {
                BaseDatos = _context.BaseDatos,
                Empresa   = empresa,
                Id        = _context.Id,
                RoleId    = _context.RoleId
            };
            var serviceTarifasDefecto = new TarifasbaseService(newContext, _db);
            var list = serviceTarifasDefecto.getAll().OfType <TarifasbaseModel>();

            var service = new TarifasService(newContext, _db);

            foreach (var item in list)
            {
                var newItem = new TarifasModel();
                newItem.Empresa     = empresa;
                newItem.Id          = item.Fktarifa;
                newItem.Descripcion = item.Descripcion;
                newItem.Tipoflujo   = item.Tipoflujo;
                newItem.Tipotarifa  = TipoTarifa.Sistema;
                service.create(newItem);
            }
        }
        public void CrearModel(string linea, EmpresaModel empresa)
        {
            var newContext = new ContextLogin()
            {
                BaseDatos = ContextService.BaseDatos,
                Empresa   = empresa.Id,
                Id        = ContextService.Id,
                RoleId    = ContextService.RoleId
            };

            var vector = linea.Split(';');
            var model  = new CuentasModel()
            {
                Empresa           = empresa.Id,
                Id                = vector[0],
                Descripcion2      = vector[1],
                Descripcion       = vector[2],
                Nivel             = int.Parse(vector[3]),
                FkPais            = empresa.Fkpais,
                UsuarioId         = Guid.Empty.ToString(),
                Nif               = new NifCifModel(),
                Fechaalta         = DateTime.Now,
                FechaModificacion = DateTime.Now
            };

            var service = new CuentasService(newContext);

            service.create(model);
        }
Exemple #3
0
        private void CrearEjercicio(string empresa, EjerciciosModel ejercicioNuevo)
        {
            ejercicioNuevo.Empresa = empresa;
            var newContext = new ContextLogin()
            {
                BaseDatos = _context.BaseDatos,
                Empresa   = empresa,
                Id        = _context.Id,
                RoleId    = _context.RoleId
            };

            var service = new EjerciciosService(newContext, _db);

            service.create(ejercicioNuevo);
        }
Exemple #4
0
        public void CrearPlanGeneral(string empresa, string plangeneralid, string pais)
        {
            var newContext = new ContextLogin()
            {
                BaseDatos = _context.BaseDatos,
                Empresa   = empresa,
                Id        = _context.Id,
                RoleId    = _context.RoleId
            };

            var service = new PlanesGeneralesService(newContext, _db);
            var item    = service.get(plangeneralid) as PlanesGeneralesModel;

            var cuentasStartup = new Startup.CuentasStartup(newContext, _db, empresa, pais);

            cuentasStartup.CrearDatos(item.Fichero);
        }
Exemple #5
0
        private void CrearCarpetas(string id)
        {
            var newContext = new ContextLogin()
            {
                BaseDatos = _context.BaseDatos,
                Empresa   = id,
                Id        = _context.Id,
                RoleId    = _context.RoleId
            };
            var serviceCarpetas = FService.Instance.GetService(typeof(CarpetasModel), newContext, _db);

            serviceCarpetas.create(new CarpetasModel()
            {
                Empresa = id,
                Id      = Guid.Empty,
                Nombre  = "Root",
                Ruta    = "Root"
            });
        }
Exemple #6
0
        private void CrearDatosModel <T>(string linea, string empresa) where T : class
        {
            var archivo = _context.ServerMapPath(linea);
            var service = new Serializer <T>();
            var model   = service.SetXml(File.ReadAllText(archivo)) as IModelView;

            if (model.getProperties().Any(f => f.property.Name.ToLower() == "empresa"))
            {
                model.set("empresa", empresa);
            }

            var newContext = new ContextLogin()
            {
                BaseDatos = _context.BaseDatos,
                Empresa   = empresa,
                Id        = _context.Id,
                RoleId    = _context.RoleId
            };
            var serviceModelo = FService.Instance.GetService(typeof(T), newContext, _db);

            serviceModelo.create(model);
        }
Exemple #7
0
        public ActionResult Index(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var context       = new ContextLogin();
                    var licenciaModel = new LicenciasaplicacionService(_dominio);
                    context.BaseDatos = licenciaModel.Basedatos;
                    context.Azureblob = licenciaModel.Azureblob;
                    using (var startupService = new StartupService(context, context.BaseDatos))
                    {
                        if (startupService.ExisteAdmin()) //esto no deberia estar aqui!
                        {
                            HttpCookie securityCookie;
                            if (_loginService.Login(_dominio, model.Usuario, model.Contraseña, out securityCookie))
                            {
                                //ensure != null
                                securityCookie.Expires = DateTime.Now.AddMinutes(120);
                                Response.Cookies.Add(securityCookie);
                                if (model.Recordarme)
                                {
                                    WebHelper.CreateCookie("login", $"{model.Usuario}#{licenciaModel.Basedatos}");
                                }
                                else
                                {
                                    WebHelper.RemoveCookie();
                                }

                                return(RedirectToLocal(model.ReturUrl));
                            }

                            ModelState.AddModelError("", "Usuario, contraseña o base de datos incorrectas");
                        }
                        else
                        {
                            return(RedirectToAction("Admin", "Startup", new { id = licenciaModel.Basedatos }));
                        }
                    }
                }
                catch (LicenciaException ex)
                {
                    ModelState.AddModelError("", ex.Message); //añadir lenguaje settings
                }
                catch (UsuarioactivoException ex)
                {
                    ModelState.AddModelError("", ex.Message); //añadir lenguaje settings
                }
                catch (UsuarioensuoException ex)
                {
                    model.Usuariobloqueado = true;
                }

                //Rai
                catch (CambiarEmpresaException ex)
                {
                    ModelState.AddModelError("", ex.Message); //añadir lenguaje settings
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", "Usuario, contraseña o base de datos incorrectas");//añadir lenguaje settings
                }
            }

            return(View(model));
        }