示例#1
0
        private static void UpdateDim(string empresa, CatCliente cat, DimClientes dim, NpgsqlConnection conn)
        {
            NpgsqlCommand cmd;

            string sqlString = "UPDATE dim_clientes " +
                               "SET codigo_cliente=@codigo, " +
                               "nombre_cliente=@nombre, " +
                               "es_local=@local, " +
                               "empresa=@empresa " +
                               "WHERE id_cliente=@id;";


            cmd = new NpgsqlCommand(sqlString, conn);

            cmd.Parameters.Add("@codigo", NpgsqlTypes.NpgsqlDbType.Varchar, 11);
            cmd.Parameters.Add("@nombre", NpgsqlTypes.NpgsqlDbType.Varchar, 250);
            cmd.Parameters.Add("@local", NpgsqlTypes.NpgsqlDbType.Boolean);
            cmd.Parameters.Add("@empresa", NpgsqlTypes.NpgsqlDbType.Varchar, 150);
            cmd.Parameters.Add("@id", NpgsqlTypes.NpgsqlDbType.Integer);

            cmd.Parameters["@codigo"].Value  = cat.CodigoCliente;
            cmd.Parameters["@nombre"].Value  = cat.RazonSocial;
            cmd.Parameters["@local"].Value   = cat.EsLocal;
            cmd.Parameters["@empresa"].Value = dim.Empresa;
            cmd.Parameters["@id"].Value      = dim.IdCliente;

            cmd.ExecuteNonQuery();
        }
示例#2
0
 public ActionResult CrearCliente([Bind] CatCliente clientes)
 {
     if (ModelState.IsValid)
     {
         objCliente.AgregarClientes(clientes);
         TempData["clienteOK"] = "Se registro correctamente el cliente.";
         return(RedirectToAction("Index"));
     }
     else
     {
         TempData["clienteError"] = "No se pudo registrar el cliente, intentelo más tarde.";
     }
     return(View(clientes));
 }
示例#3
0
 public ActionResult CrearCliente([Bind] CatCliente clientes)
 {
     if (ModelState.IsValid)
     {
         objCliente.AgregarClientes(clientes);
         TempData["clienteOK"] = "The customer was registered correctly.";
         return(RedirectToAction("Index"));
     }
     else
     {
         TempData["clienteError"] = "The customer can not be registered, try it later.";
     }
     return(View(clientes));
 }
示例#4
0
        public ActionResult Detalles(int?id)
        {
            if (id == null)
            {
                return(View());
            }

            CatCliente clientes = objCliente.ConsultarListaClientes(id);

            if (clientes == null)
            {
                return(View());
            }
            return(View(clientes));
        }
示例#5
0
        public CatCliente GetCatCliente(int claCliente)
        {
            var catCliente = new CatCliente();

            using (IDbConnection con = new SqlConnection(Global.ConnectionString))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                catCliente = con.Query <CatCliente>(
                    "select ClaCliente, NomCliente, ApiKey, Descripcion from KraSch.KraCatCliente where ClaCliente = " +
                    claCliente.ToString()).FirstOrDefault();
            }

            return(catCliente);
        }
示例#6
0
 public ActionResult Editar(int id, [Bind] CatCliente clientes)
 {
     if (id != clientes.Customer)
     {
         return(View());
     }
     if (ModelState.IsValid)
     {
         objCliente.ActualizarCliente(clientes);
         TempData["clienteEditar"] = "Se modifico correctamente el cliente.";
         return(RedirectToAction("Index"));
     }
     else
     {
         TempData["clienteEditarError"] = "No se pudo modificar el cliente, intentelo más tarde.";
     }
     return(View(clientes));
 }
示例#7
0
 public ActionResult Editar(int id, [Bind] CatCliente clientes)
 {
     if (id != clientes.Customer)
     {
         return(View());
     }
     if (ModelState.IsValid)
     {
         objCliente.ActualizarCliente(clientes);
         TempData["clienteEditar"] = "The customer was modified correctly.";
         return(RedirectToAction("Index"));
     }
     else
     {
         TempData["clienteEditarError"] = "The client could not be modified, try it later.";
     }
     return(View(clientes));
 }
示例#8
0
        private static void LoadDim(string empresa, int idEmpresa, CatCliente cat, NpgsqlConnection conn)
        {
            NpgsqlCommand cmd;

            string sqlString = "INSERT INTO dim_clientes(codigo_cliente, nombre_cliente, es_local, empresa, id_empresa)" +
                               "VALUES(@codigo, @nombre, @local, @empresa, @idEmpresa);";


            cmd = new NpgsqlCommand(sqlString, conn);

            cmd.Parameters.Add("@codigo", NpgsqlTypes.NpgsqlDbType.Varchar, 11);
            cmd.Parameters.Add("@nombre", NpgsqlTypes.NpgsqlDbType.Varchar, 250);
            cmd.Parameters.Add("@local", NpgsqlTypes.NpgsqlDbType.Boolean);
            cmd.Parameters.Add("@empresa", NpgsqlTypes.NpgsqlDbType.Varchar, 150);
            cmd.Parameters.Add("@idEmpresa", NpgsqlTypes.NpgsqlDbType.Integer);

            cmd.Parameters["@codigo"].Value    = cat.CodigoCliente;
            cmd.Parameters["@nombre"].Value    = cat.RazonSocial;
            cmd.Parameters["@local"].Value     = cat.EsLocal;
            cmd.Parameters["@empresa"].Value   = empresa;
            cmd.Parameters["@idEmpresa"].Value = idEmpresa;

            cmd.ExecuteNonQuery();
        }
示例#9
0
        public void MineMonitors(EventLog log)
        {
            var configuredClients = ConfigurationManager.AppSettings as NameValueCollection;

            if (configuredClients == null)
            {
                log.WriteEntry("Unable to load the configuration file.", EventLogEntryType.Warning, 13, 1);
                return;
            }

            if (configuredClients.Count == 0)
            {
                log.WriteEntry("No keys detected in configuration file.", EventLogEntryType.Warning, 14, 1);
                return;
            }

            //PgDbCollector.CleanFactDocument();

            foreach (var key in configuredClients.AllKeys)
            {
                string configuredClient = configuredClients.GetValues(key).FirstOrDefault();
                if ("libDir".Equals(key.ToString()))
                {
                    continue;
                }

                EnterpriseSection clientConfig = (EnterpriseSection)System.Configuration.ConfigurationManager.GetSection("Empresas/" + configuredClient);

                if (clientConfig == null)
                {
                    log.WriteEntry("Client configuration not found for Empresas/" + configuredClient + ".", EventLogEntryType.Warning, 15, 1);
                    continue;
                }

                Empresa empresa = PgDbCollector.GetCompanyByName(clientConfig.NombreEmpresa);
                log.WriteEntry("Client configuration found in database: " + clientConfig.NombreEmpresa + "; " + empresa.Ruta);

                NpgsqlConnection conn             = new NpgsqlConnection();
                string           connectionString = ConfigurationManager.ConnectionStrings[Config.Common.JASPER].ConnectionString;
                conn = new NpgsqlConnection(connectionString);
                conn.Open();

                if (empresa != null)
                {
                    log.WriteEntry("Invoice codes found for " + clientConfig.NombreEmpresa + " as [" + clientConfig.CodigosFactura + "]", EventLogEntryType.Information, 16, 1);
                    log.WriteEntry("Payment codes found for " + clientConfig.NombreEmpresa + " as [" + clientConfig.CodigosPago + "]", EventLogEntryType.Information, 17, 1);
                    log.WriteEntry("Sale codes found for " + clientConfig.NombreEmpresa + " as [" + clientConfig.CodigosVenta + "]", EventLogEntryType.Information, 17, 1);
                    log.WriteEntry("Return codes found for " + clientConfig.NombreEmpresa + " as [" + clientConfig.CodigosDevolucion + "]", EventLogEntryType.Information, 17, 1);
                    string[] facturas   = clientConfig.CodigosFactura.Split(',');
                    string[] abonos     = clientConfig.CodigosPago.Split(',');
                    string[] venta      = clientConfig.CodigosVenta.Split(',');
                    string[] devolucion = clientConfig.CodigosDevolucion.Split(',');
                    try
                    {
                        //AdminPaqImpl.DownloadMonitors(venta, devolucion, facturas, abonos, empresa, log);

                        log.WriteEntry("Downloading from AdminPaq: " + empresa.Ruta, EventLogEntryType.Information, 8, 2);
                        // DIM ETLs
                        List <CatCliente> clientes = CatCliente.GetClientes(empresa.Ruta);
                        log.WriteEntry(clientes.Count + " clientes found for " + empresa.Nombre + " in AdminPaq", EventLogEntryType.Information, 9, 2);
                        ETLClientes.Execute(empresa.Id, empresa.Nombre, clientes, conn);

                        List <CatSeller> sellers = CatSeller.GetSellers(empresa.Ruta);
                        log.WriteEntry(sellers.Count + " agents found for " + empresa.Nombre + " in AdminPaq", EventLogEntryType.Information, 10, 2);
                        ETLSellers.Execute(empresa.Id, empresa.Nombre, sellers, conn);

                        ETLMeses.Execute(conn);

                        // FACT Preparation
                        FactVencido vencido = new FactVencido();
                        vencido.Prepare(empresa.Id, empresa.Ruta, conn);
                        log.WriteEntry(string.Format("Prepared due documents for {0}", empresa.Nombre), EventLogEntryType.Information, 11, 2);

                        FactPorVencer porVencer = new FactPorVencer();
                        porVencer.Prepare(empresa.Id, empresa.Ruta, conn);
                        log.WriteEntry(string.Format("Prepared documents about to due for {0}", empresa.Nombre), EventLogEntryType.Information, 12, 2);

                        FactCobranza cobranza = new FactCobranza();
                        cobranza.Prepare(empresa.Id, empresa.Ruta, conn);
                        log.WriteEntry(string.Format("Prepared collection documents for {0}", empresa.Nombre), EventLogEntryType.Information, 13, 2);

                        FactSales factSale = new FactSales();
                        factSale.Prepare(empresa.Id, empresa.Ruta, conn);
                        log.WriteEntry(string.Format("Prepared sale documents for {0}", empresa.Nombre), EventLogEntryType.Information, 14, 2);

                        // FILL FACTS
                        DocsMiner dMiner = new DocsMiner();
                        dMiner.Vencidos  = vencido.GruposVencimiento;
                        dMiner.PorVencer = porVencer.GruposVencimiento;
                        dMiner.Cobranza  = cobranza.GruposCobranza;
                        dMiner.Ventas    = factSale.GruposVenta;

                        log.WriteEntry(string.Format("Mining documents for {0} started", empresa.Nombre), EventLogEntryType.Information, 15, 2);

                        dMiner.Execute(empresa, facturas, abonos, venta, devolucion, log);
                        log.WriteEntry(string.Format("Mining documents for {0} completed", empresa.Nombre), EventLogEntryType.Information, 16, 2);

                        MainLoader loader = new MainLoader();
                        loader.Vencidos  = dMiner.Vencidos;
                        loader.PorVencer = dMiner.PorVencer;
                        loader.Cobranza  = dMiner.Cobranza;
                        loader.Ventas    = dMiner.Ventas;

                        log.WriteEntry(string.Format("Loading documents for {0} started", empresa.Nombre), EventLogEntryType.Information, 17, 2);
                        loader.Load(empresa.Id, conn);
                        log.WriteEntry(string.Format("Loading documents for {0} completed", empresa.Nombre), EventLogEntryType.Information, 18, 2);
                    }catch (Exception ex) {
                        log.WriteEntry("Exception while mining monitors: " + ex.Message + " || " + ex.StackTrace, EventLogEntryType.Error, 19, 2);
                    }
                }
                conn.Close();
            }
        }