public void cargarPersonalizacion(string url) { try { //Personalizacion IDALTienda it = new DALTiendaEF(); String fileName = "_ViewStart.cshtml"; var filePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Views"), fileName); Personalizacion p = it.ObtenerPersonalizacionTienda(url); String layout = "@{Layout = \"~/Views/Shared/_Layout.cshtml\";}"; if (p.template != null && p.template == 1) { layout = "@{Layout = \"~/Views/Shared/_Layout.cshtml\";}"; String cssFileName = "orangeStyle.css"; var cssFilePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/personalizacion/EstiloUno"), cssFileName); if (p.css != null) { //Escribir css System.IO.File.WriteAllText(cssFilePath, p.css); } else { var orangePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/personalizacion/EstiloUno"), "orangeStyle_backup.css"); String orangeStyle = System.IO.File.ReadAllText(orangePath); System.IO.File.WriteAllText(cssFilePath, orangeStyle); } } else if (p.template != null && p.template == 2) { layout = "@{Layout = \"~/Views/Shared/_Layout2.cshtml\";}"; String cssFile = "fixes.css"; String cssFileBackup = "fixes_backup.css"; var cssPathBackup = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/personalizacion/EstiloDos"), cssFileBackup); //Original css String cssText = System.IO.File.ReadAllText(cssPathBackup); var imgUrl = ""; if (p.backgroud_image != null) { imgUrl = Request.Url.Scheme + "://" + Request.Url.Authority + "/" + url + "/Product/getTiendaImg"; } else { //Por default imgUrl = "images/bg01.png"; } cssText = cssText.Replace("body {}", "body {background-image: url(" + imgUrl + ")}"); //Escribimos el css editado var cssPath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/personalizacion/EstiloDos"), cssFile); System.IO.File.WriteAllText(cssPath, cssText); } Session["Tienda_Desc"] = p.tienda.descripcion; //Escribimos el layout a usar que carga todos los css para esa pers. System.IO.File.WriteAllText(filePath, layout); } catch (Exception ex) { } }
public void Run(string tiendaID) { IDALUsuario udal = new DALUsuarioEF(); IDALTienda tdal = new DALTiendaEF(); IDALSubasta sdat = new DALSubastaEF(); Tienda tienda = tdal.ObtenerTienda(tiendaID); List <Producto> productos = sdat.ObtenerTodosProductos(tienda.TiendaID); //obtengo algoritmo Personalizacion pers = tdal.ObtenerPersonalizacionTienda(tienda.TiendaID); List <Usuario> usuarios = udal.ObtenerTodosUsuariosFull(tienda.TiendaID); bool defaultalgorithm = false; if (pers.algoritmo == null || pers.algoritmo.Length == 0) { defaultalgorithm = true; } //creo indice Task index = udal.InicializarColeccionRecomendaciones(tienda.TiendaID); index.Wait(); foreach (var user in usuarios) { if (defaultalgorithm) { Algorithms def = new Algorithms(); def.default_recomendation_algorithm(productos, user, tienda.TiendaID); } else { Algorithms a = new Algorithms(); a.custom_algorithm(pers, productos, user, tienda.TiendaID); } }//IF tienda es de instancia... }