private void AgregarProducto_Click(object sender, EventArgs e) { try { Metrica m = new Metrica(); m.Medida = cboMetrica.SelectedValue.ToString(); Producto p = new Producto(); p.Codigo = txtCodigoProducto.Text; p.Nombre = txtNombreProducto.Text; p.Proveedor = new Proveedor { Id = int.Parse(cboProveedor.SelectedValue.ToString()) }; p.Metrica = m; if (p.Agregar()) { MenuAdministrador_Load(sender, e); MetroFramework.MetroMessageBox.Show(this, "Producto Agregado", "Agregar Producto"); return; } MetroFramework.MetroMessageBox.Show(this, "El producto número " + txtCodigoProducto.Text + " ya existe", "Agregar Producto"); } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, "Error" + ex.Message, "Agregar Mesa"); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Indice,Data,Unidade,Peso,Template,Planejado,Executado,Razao,ParecerDescritivo,LkpObjetivo,LkpPessoa,LkpPlanoAcao,LkpTarefaStatus,LkpStatusDetalheTarefa,LkpMetrica")] Metrica metrica) { if (id != metrica.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(metrica); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MetricaExists(metrica.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LkpMetrica"] = new SelectList(_context.Metrica, "Id", "Id", metrica.LkpMetrica); ViewData["LkpObjetivo"] = new SelectList(_context.Objetivo, "Id", "Titulo", metrica.LkpObjetivo); ViewData["LkpPessoa"] = new SelectList(_context.Pessoas, "Id", "Id", metrica.LkpPessoa); ViewData["LkpPlanoAcao"] = new SelectList(_context.PlanoAcao, "Id", "Id", metrica.LkpPlanoAcao); ViewData["LkpStatusDetalheTarefa"] = new SelectList(_context.TarefaStatusDetalhe, "Id", "Id", metrica.LkpStatusDetalheTarefa); ViewData["LkpTarefaStatus"] = new SelectList(_context.TarefaStatus, "Id", "Id", metrica.LkpTarefaStatus); return(View(metrica)); }
private void ModificarProducto_Click(object sender, EventArgs e) { try { Metrica m = new Metrica(); m.Id = idMetrica; m.Medida = cboMetrica.SelectedValue.ToString(); Producto p = new Producto(); p.Codigo = txtCodigoProducto.Text; p.Nombre = txtNombreProducto.Text; p.Proveedor = new Proveedor { Id = int.Parse(cboProveedor.SelectedValue.ToString()) }; p.Metrica = m; if (p.Modificar()) { MenuAdministrador_Load(sender, e); MetroFramework.MetroMessageBox.Show(this, "Producto Modificado", "Modificar Producto"); } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, "Error" + ex.Message, "Modificar Producto"); } }
public async Task <IActionResult> Edit(int id, [Bind("IdMetrica,IdSubcaracteristica,IdCaracteristica,Nombre")] Metrica metrica) { if (id != metrica.IdMetrica) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(metrica); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MetricaExists(metrica.IdMetrica)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdCaracteristica"] = new SelectList(_context.Caracteristica, "IdCaracteristica", "Nombre", metrica.IdCaracteristica); ViewData["IdSubcaracteristica"] = new SelectList(_context.Subcaracteristica, "IdSubcaracteristica", "Nombre", metrica.IdSubcaracteristica); return(View(metrica)); }
public ActionResult Create(MetricaView model) { try { if (ModelState.IsValid) { var metrica = new Metrica { FrequenciaAfericaoId = model.FrequenciaAfericaoId, Nome = model.Nome, Descricao = model.Descricao, Formula = model.Formula }; Context.Metrica.Add(metrica); Context.SaveChanges(); return(RedirectToAction(nameof(Index))); } ViewBag.MedidasMetricas = new List <MedidaMetricaView>(); ViewBag.Medidas = Context.Medida.AsEnumerable(); ViewBag.FrequenciasAfericao = Context.FrequenciaAfericao.AsEnumerable(); return(View()); } catch { ViewBag.MedidasMetricas = new List <MedidaMetricaView>(); ViewBag.Medidas = Context.Medida.AsEnumerable(); ViewBag.FrequenciasAfericao = Context.FrequenciaAfericao.AsEnumerable(); return(View()); } }
public override List <List <T> > clusterize(List <T> set, Metrica <T> metrica, int count) { initialize(set, metrica, count); do { calculateAssiciationMatrix(); moveCenters(); } while (ifLoss()); return(prepareResult()); }
private void bntGuardarIngrediente_Click(object sender, EventArgs e) { try { //Guardaremos primero una clase metrica para nuestra entidad ingrediente Metrica metrica = new Metrica(); metrica.Medida = cboMedidaIngrediente.SelectedItem.ToString(); metrica.Peso = int.Parse(txtPesoIngrediente.Text); //Rescatamos el id de la metrica para guardarlo en la entidad ingrediente int idMetrica = metrica.Agregar(); if (idMetrica == 0) { //Aca caera si no se puede agregar la metrica. Mandamos el mensaje txtPesoIngrediente.Clear(); MetroFramework.MetroMessageBox.Show(this, "No se pudo agregar el ingrediente."); } //Crearemos un ingrediente con la metrica correspondiente agregada Ingrediente ing = new Ingrediente(); ing.Cantidad = int.Parse(txtCantidadIngrediente.Text); ing.Nombre = txtNombreIngrediente.Text; ing.Menu = new Modelo.Menu { Id = int.Parse(cboMenuIngrediente.SelectedValue.ToString()) }; ing.Producto = new Producto { Id = int.Parse(cboProductoIngrediente.SelectedValue.ToString()) }; ing.Metrica = new Metrica { Id = idMetrica }; //Preguntamos si el producto a sido agregado correctamente if (ing.Agregar()) { txtCantidadIngrediente.Clear(); txtNombreIngrediente.Clear(); txtPesoIngrediente.Clear(); //Cargamos el menu de ingrediente denuevo para ver el cambio que se agrego ingredientito.Comandas_Load(sender, e); //El ingrediente se guardo correctamente MetroFramework.MetroMessageBox.Show(this, "Se agrego el ingrediente correctamente"); Close(); } else { //El ingrediente no se guardo correctamente MetroFramework.MetroMessageBox.Show(this, "No se agrego el ingrediente correctamente"); } } catch (Exception) { MetroFramework.MetroMessageBox.Show(this, "No se agrego el ingrediente correctamente"); throw; } }
public async Task <IActionResult> Create([Bind("IdMetrica,IdSubcaracteristica,IdCaracteristica,Nombre")] Metrica metrica) { if (ModelState.IsValid) { _context.Add(metrica); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdCaracteristica"] = new SelectList(_context.Caracteristica, "IdCaracteristica", "Nombre", metrica.IdCaracteristica); ViewData["IdSubcaracteristica"] = new SelectList(_context.Subcaracteristica, "IdSubcaracteristica", "Nombre", metrica.IdSubcaracteristica); return(View(metrica)); }
public CompareHelper() { m_Metrica = Metrica.Metric; m_Graphs = new List <KeyValuePair <string, List <Graph> > >(); m_Dimensions = new Dictionary <string, int>(); m_Sources = new ObservableCollection <CompareSource>(); m_Sources.CollectionChanged += OnSourcesChanged; m_AvailableOrdinates = new ObservableCollection <CheckedListItem <string> >(); m_AvailableSources = new ObservableCollection <CheckedListItem <string> >(); m_Imperical2MetricalConverter = new ImperialToMetricalConverter(); m_Metrical2ImperialConverter = new MetricalToImperialConverter(); }
public async Task <IActionResult> Create([Bind("Id,Nome,Indice,Data,Unidade,Peso,Template,Planejado,Executado,Razao,ParecerDescritivo,LkpObjetivo,LkpPessoa,LkpPlanoAcao,LkpTarefaStatus,LkpStatusDetalheTarefa,LkpMetrica")] Metrica metrica) { if (ModelState.IsValid) { _context.Add(metrica); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LkpMetrica"] = new SelectList(_context.Metrica, "Id", "Nome", metrica.LkpMetrica); ViewData["LkpObjetivo"] = new SelectList(_context.Objetivo, "Id", "Id", metrica.LkpObjetivo); ViewData["LkpPessoa"] = new SelectList(_context.Pessoas, "Id", "Id", metrica.LkpPessoa); ViewData["LkpPlanoAcao"] = new SelectList(_context.PlanoAcao, "Id", "Id", metrica.LkpPlanoAcao); ViewData["LkpStatusDetalheTarefa"] = new SelectList(_context.TarefaStatusDetalhe, "Id", "Id", metrica.LkpStatusDetalheTarefa); ViewData["LkpTarefaStatus"] = new SelectList(_context.TarefaStatus, "Id", "Id", metrica.LkpTarefaStatus); return(View(metrica)); }
private void CargaMetrica(string id_metrica) { Metrica m = ConsultaMetricasBD(id_metrica); text_id.Text = m.Id; textNombre.Text = m.Nombre; textProposito.Text = m.Proposito; textMetodo.Text = m.Metodo; textFormula.Text = m.Formula; textMejorValor.Text = m.MejorValor; textPeorValor.Text = m.PeorValor; textPerspectiva.Text = m.Perspectiva; textidSubcaracteristica.Text = m.SubCaracteristica; textVariables.Text = m.Variables; textDescripcionv1.Text = m.DescripcionA; textDescripcionv2.Text = m.DescripcionB; }
public override List <List <T> > clusterize(List <T> set, Metrica <T> metrica, int count) { this.initialize(set, metrica, count); Console.WriteLine("Starting clusterization"); while (operatingClusters.Count > this.clustersCount) { int firstCluster = 0; int secondCluster = 1; this.getMinPositions(out firstCluster, out secondCluster); this.uniteClusters(firstCluster, secondCluster); if (operatingClusters.Count % 100 == 0) { Console.WriteLine(operatingClusters.Count); } } return(prepareResult()); }
private void initialize(List <T> set, Metrica <T> metrica, int count) { centers = new BaseFuzzyObject[count]; clustersCount = count; this.set = set; this.metrica = metrica; associationMatrix = new double[set.Count][]; for (int i = 0; i < set.Count; i++) { associationMatrix[i] = new double[count]; } var rand = new Random(); for (int i = 0; i < count; i++) { centers[i] = metrica.multiply(set[rand.Next(set.Count)], 1); } }
public void MenuAdministrador_Load(object sender, EventArgs e) { // TODO: esta línea de código carga datos en la tabla 'dS_Siglo21.DTProveedor' Puede moverla o quitarla según sea necesario. this.dTProveedorTableAdapter.Fill(this.dS_Siglo21.DTProveedor); // TODO: esta línea de código carga datos en la tabla 'dS_Siglo21.DTUsuario' Puede moverla o quitarla según sea necesario. this.dTUsuarioTableAdapter.Fill(this.dS_Siglo21.DTUsuario); // TODO: esta línea de código carga datos en la tabla 'dS_Siglo21.DTMesa' Puede moverla o quitarla según sea necesario. this.dTMesaTableAdapter.Fill(this.dS_Siglo21.DTMesa); // TODO: esta línea de código carga datos en la tabla 'dS_Siglo21.DTProducto' Puede moverla o quitarla según sea necesario. this.dTProductoTableAdapter.Fill(this.dS_Siglo21.DTProducto); // TODO: esta línea de código carga datos en la tabla 'dS_Siglo21.PROVEEDOR' Puede moverla o quitarla según sea necesario. this.pROVEEDORTableAdapter.Fill(this.dS_Siglo21.PROVEEDOR); // TODO: esta línea de código carga datos en la tabla 'dS_Siglo21.SOLICITUD' Puede moverla o quitarla según sea necesario. this.sOLICITUDTableAdapter.Fill(this.dS_Siglo21.SOLICITUD); // TODO: esta línea de código carga datos en la tabla 'dS_Siglo21.ESTADO_SOLICITUD' Puede moverla o quitarla según sea necesario. this.eSTADO_SOLICITUDTableAdapter.Fill(this.dS_Siglo21.ESTADO_SOLICITUD); cboMetrica.DataSource = Metrica.metricas(); cboMetrica.DisplayMember = "Medida"; cboMetrica.ValueMember = "Medida"; }
private void initialize(List <T> set, Metrica <T> metrica, int count) { clustersCount = count; this.set = set; this.metrica = metrica; clusters = new List <int> [set.Count]; clustersDistances = new double[set.Count][]; objectsDistances = new double[set.Count][]; operatingClusters = new List <int>(); for (int i = 0; i < set.Count; i++) { //сначала каждый кластер содержит один элемент clusters[i] = new List <int>(); clusters[i].Add(i); clustersDistances[i] = new double[i]; objectsDistances[i] = new double[i]; operatingClusters.Add(i); } Task[] tasks = new Task[threadCount]; int step = (int)Math.Ceiling((double)clustersDistances.Length / threadCount); for (int i = 0; i < threadCount; i++) { Tuple <int, int> coordinates = new Tuple <int, int>(i, threadCount); tasks[i] = Task.Factory.StartNew((tuple) => { initializeDistances(((Tuple <int, int>)tuple).Item1, ((Tuple <int, int>)tuple).Item2); return; }, coordinates); } Task.WaitAll(tasks); for (int i = 0; i < threadCount; i++) { tasks[i].Dispose(); } }
private Metrica ConsultaMetricasBD(string idMetrica) { Metrica m = new Metrica(); string consulta = "select * from metrica where id = '" + idMetrica + "';"; NpgsqlConnection conexionBD = new NpgsqlConnection(ParametrosConexionBD.BD); conexionBD.Open(); //informacion gral NpgsqlCommand comandoInfoMetrica = new NpgsqlCommand(consulta, conexionBD); NpgsqlDataReader drInfoMetrica = comandoInfoMetrica.ExecuteReader(); while (drInfoMetrica.Read()) { m.Id = drInfoMetrica["id"].ToString(); m.Nombre = drInfoMetrica["nombre"].ToString(); m.Proposito = drInfoMetrica["proposito"].ToString(); m.Metodo = drInfoMetrica["metodo"].ToString(); m.Formula = drInfoMetrica["formula"].ToString(); m.MejorValor = drInfoMetrica["mejor_valor"].ToString(); m.PeorValor = drInfoMetrica["peor_valor"].ToString(); m.Perspectiva = drInfoMetrica["id_perspectiva"].ToString(); m.SubCaracteristica = drInfoMetrica["id_subcaracteristica"].ToString(); m.Variables = drInfoMetrica["variables"].ToString(); m.DescripcionA = drInfoMetrica["descripcion_a"].ToString(); m.DescripcionB = drInfoMetrica["descripcion_b"].ToString(); } conexionBD.Close(); return(m); }
public abstract List <List <T> > clusterize(List <T> set, Metrica <T> metrica, int count);
public SumTripletMetrica(Metrica <T> baseMetrica) { this.baseMetrica = baseMetrica; }
private static void clusterizeAndSave(ClusteringMethod <Triplet <Word> > method, Metrica <Triplet <Word> > metrica, int count) { Console.WriteLine("Clustering method " + method.ToString()); Console.WriteLine("Metrica " + metrica.ToString()); var path = "..\\" + method.ToString() + "\\" + metrica.ToString() + "\\"; Directory.CreateDirectory(path); var result = method.clusterize(data, metrica, count); var format = new XmlSerializer(typeof(List <Triplet <Word> >)); var statFormat = new BinaryFormatter(); resultItemsCount = 0; FileStream stream; for (int i = 0; i < result.Count; i++) { resultItemsCount += result[i].Count; var fileName = path + "clustersResult" + i + ".xml"; stream = File.Create(fileName); format.Serialize(stream, result[i]); stream.Close(); var fs = File.OpenWrite(path + "clusterStat" + i + ".txt"); var stat = getStatForCluster(result[i], fs); fs.Close(); } var dataStat = getStatForCluster(data, File.OpenWrite(path + "dataStat.txt")); }
// GET: Objetivoes public async Task <IActionResult> Index() { var meunegocioContext = _context.Objetivo.Include(o => o.LkpMetricaNavigation).Include(o => o.LkpPerspectivaNavigation).Include(o => o.LkpPessoaNavigation).Include(o => o.LkpResponsavelNavigation); /* INICIO */ Perfil objPerfil = _context.Perfil.Where(pr => pr.LkpPessoa == _context.Pessoas.Where(ps => ps.Email == "*****@*****.**").First().Id).First(); Metrica objMetricaPadrao = new Metrica(); var colCamadas = _context.Bsc.Where(b => b.Id != null); int contadorCamada = 0, contadorObjetivo = 0; var colObjetivo = _context.Objetivo.Where(o => o.Id != null); List <decimal> listaDesempenhoCamada = new List <decimal>(); List <decimal> listaDesempenhoObjetivo = new List <decimal>(); List <decimal> listaAuxiliarDesempenhoObjetivo = new List <decimal>(); List <String> corFundoCamada = new List <string>(); List <String> corBordaCamada = new List <string>(); List <String> corFundoObjetivo = new List <string>(); List <String> corBordaObjetivo = new List <string>(); List <PlanoAcao> colPlanoAcaoCamada = new List <PlanoAcao>(); foreach (var camada in _context.Bsc.Where(b => b.Id != null)) { listaAuxiliarDesempenhoObjetivo = new List <decimal>(); foreach (var objetivo in colObjetivo.Where(o => o.LkpPerspectiva == camada.Id && o.LkpPessoa == objPerfil.LkpPessoa)) { try { var objMetricaTemplate = _context.Metrica.Where(m => m.LkpObjetivo == objetivo.Id && m.Nome == "DESEMPENHO").First(); var objMetricaDesempenho = _context.Metrica.Where(m => m.LkpMetrica == objMetricaTemplate.Id).First(); /* Inserindo desempenho de cada objetivo em uma lista */ listaDesempenhoObjetivo.Add(objMetricaDesempenho.Executado); listaAuxiliarDesempenhoObjetivo.Add(objMetricaDesempenho.Executado); /* Definição de cores de fundo e borda dos objetivos */ corFundoObjetivo.Add(objMetricaPadrao.corFundo(listaDesempenhoObjetivo.Count > 0 ? listaDesempenhoObjetivo[contadorObjetivo] : -1, "Quanto maior melhor", objPerfil.getValoresCor())); corBordaObjetivo.Add(objMetricaPadrao.corBorda(listaDesempenhoObjetivo.Count > 0 ? listaDesempenhoObjetivo[contadorObjetivo] : -1, "Quanto maior melhor", objPerfil.getValoresCor())); } catch { listaDesempenhoObjetivo.Add(-1); listaAuxiliarDesempenhoObjetivo.Add(-1); /* Definição de cores de fundo e borda dos objetivos */ corFundoObjetivo.Add(objMetricaPadrao.corFundo(-1, "Quanto maior melhor", objPerfil.getValoresCor())); corBordaObjetivo.Add(objMetricaPadrao.corBorda(-1, "Quanto maior melhor", objPerfil.getValoresCor())); } contadorObjetivo += 1; } /* Inserindo desempenho de cada camada em uma lista */ if (listaAuxiliarDesempenhoObjetivo.Count() > 0) { listaDesempenhoCamada.Add(listaAuxiliarDesempenhoObjetivo.Average()); } else { listaDesempenhoCamada.Add(-1); } /* Definição de cores de fundo e borda das camadas */ corFundoCamada.Add(objMetricaPadrao.corFundo(listaDesempenhoCamada.Count > 0 ? listaDesempenhoCamada[contadorCamada] : -1, "Quanto maior melhor", objPerfil.getValoresCor())); corBordaCamada.Add(objMetricaPadrao.corBorda(listaDesempenhoCamada.Count > 0 ? listaDesempenhoCamada[contadorCamada] : -1, "Quanto maior melhor", objPerfil.getValoresCor())); /* Coleção de planos por camada */ foreach (var plano in _context.PlanoAcao.Where(p => p.LkpPerspectiva == camada.Id)) { colPlanoAcaoCamada.Add(plano); } contadorCamada += 1; } /* View Bags */ ViewBag.colMetrica = _context.Metrica.Where(m => m.LkpMetrica != null).ToList <Metrica>(); ViewBag.listaDesempenhoCamada = listaDesempenhoCamada; ViewBag.listaDesempenhoObjetivo = listaDesempenhoObjetivo; ViewBag.colTemplateMetrica = _context.Metrica.Where(m => m.Template == true && m.LkpPessoa == objPerfil.LkpPessoa && m.Nome != "DESEMPENHO"); ViewBag.colObjetivo = colObjetivo; ViewBag.colCamadas = colCamadas; ViewBag.corBordaCamada = corBordaCamada; ViewBag.corFundoCamada = corFundoCamada; ViewBag.corBordaObjetivo = corBordaObjetivo; ViewBag.corFundoObjetivo = corFundoObjetivo; ViewBag.colPlanoAcaoCamada = colPlanoAcaoCamada; return(View(await meunegocioContext.ToListAsync())); }
public MultTripletMetrica(Metrica <T> baseMetrica) { this.baseMetrica = baseMetrica; }
public void SetMetrica(Metrica metrica) { if (m_Metrica != metrica) { UnitConverter converter = null; switch (metrica) { case Metrica.Metric: converter = m_Imperical2MetricalConverter; break; case Metrica.Imperial: converter = m_Metrical2ImperialConverter; break; default: throw new InvalidOperationException("convert error"); } foreach (var source in m_Sources) { var data = source.getValues(); var units = source.getUnits(); var toConvert = data.Where(v => Array.IndexOf(converter.getConvertableUnits(), units[v.Key]) >= 0).ToArray(); foreach (var keyValue in toConvert) { string newUnit = converter.Convert(data[keyValue.Key], units[keyValue.Key]); var toUpdateX = m_Graphs.SelectMany(g => g.Value).Where(graph => graph.GraphName.Equals(source.Title + "_" + graph.YAxis + "(" + (graph.XAxis ?? "") + ")") && graph.XAxis != null && string.Equals(graph.XAxis, keyValue.Key)); var toUpdateY = m_Graphs.SelectMany(g => g.Value).Where(graph => graph.GraphName.Equals(source.Title + "_" + graph.YAxis + "(" + (graph.XAxis ?? "") + ")") && graph.YAxis != null && string.Equals(graph.YAxis, keyValue.Key)); foreach (Graph graph in toUpdateX) { graph.X_Unit = newUnit; for (int i = 0; i < keyValue.Value.Count(); i++) { graph.PointPairs[i].X = keyValue.Value[i]; } } foreach (Graph graph in toUpdateY) { graph.Y_Unit = newUnit; for (int i = 0; i < keyValue.Value.Count(); i++) { graph.PointPairs[i].Y = keyValue.Value[i]; } } units[keyValue.Key] = newUnit; } } m_Metrica = metrica; Redraw(); } }