public bool Refresh(bool forse) { if (DateTime.Now.AddMilliseconds(-RefreshRate) > LastRefresh) { Logg.Debug(new { cache = "begin refresh" }.stringify()); LastRefresh = DateTime.Now; lock (this) { var currentEtag = ETag; var currentVersion = Version; foreach (var extension in Extensions) { extension.Refresh(forse); } if (currentEtag == ETag && currentVersion == Version) { return(false); } Logg.Trace(new{ cache = "refreshed" }.stringify()); Clear(); return(true); } } return(false); }
private string GetValueFromLog(string key, Logg _log) { switch (key) { case "Gender": return(_log.Gender); case "Weather": return(_log.Weather); case "Age": return(_log.Age); case "WeaponType": return(_log.WeaponType); case "Weight": return(_log.Weight.ToString()); case "ButchWeight": return(_log.ButchWeight.ToString()); case "Tags": return(_log.Tags.ToString()); default: throw new KeyNotFoundException(key); } }
public int actualizarUsuario(CL_Usuario p_user) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "UPDATE USUARIO SET Nombre='" + p_user.Nombre + "'," + "Apellido = '" + p_user.Apellido + "'," + "Password = '******'," + "TipoUsuario = '" + p_user.TipoUsuario + "', " + "user = '******'," + "local= '" + p_user.Local + "'," + "habilitado='" + p_user.Habilitado + "'" + "WHERE idUsuario =" + p_user.IdUsuario + ""; cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
void Host_MigrateRequest(object sender, MigrateRequestEventArgs e) { DestinationClient = new Client(e.Adress, e.Port, Logg); DestinationClient.DataReceived += DestinationClient_DataReceived; Logg.Log(string.Format("Migration réussit avec succes, server de jeux : {0}: {1} .", e.Adress, e.Port), LogLevelEnum.Succes); Host.Bot.BotState = BotStatsEnum.INACTIF; }
private async Task ExecutePhase(IReportContext context, ReportPhase phase, IScope scope) { Logg.Debug(new { op = "start phase", phase }); var agents = context.Agents.Where(_ => _.Phase.HasFlag(phase)).OrderBy(_ => _.Idx).GroupBy(_ => _.Idx).ToArray(); foreach (var grp in agents) { if (grp.Count() == 1) { await grp.First().Execute(context, phase, scope); } else if (grp.All(_ => _.Parallel)) { var waitgroup = new List <Task>(); foreach (var agent in grp) { waitgroup.Add(agent.Execute(context, phase, scope)); } Task.WaitAll(waitgroup.ToArray()); } else { foreach (var agent in grp) { await agent.Execute(context, phase, scope); } } } Logg.Debug(new { op = "end phase", phase }); }
//SELECT DISTINCT(local) from usuario; public List <string> obtenerLocales() { List <string> lista = new List <string>(); try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "SELECT DISTINCT(local) as local from usuario"; cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string aux = ""; aux = dr["local"].ToString(); lista.Add(aux); } cone.Close(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(null); } return(lista); }
private void LogStart(string username, string password, IScope context, string opid) { if (Logg.IsForDebug()) { Logg.Debug(new { opid, username, pass = password.GetMd5(), context }.stringify()); } }
private IIdentity AuthenticateWithValidToken(IHttpRequestDescriptor request, Token currentToken) { var currentExpire = currentToken.Expire.ToUniversalTime(); Token token; if (IsProlongable(request)) { token = TokenService.Prolongate(currentToken); } else { token = currentToken; } var resultExpire = token.Expire.ToUniversalTime(); if (Logg.IsForDebug()) { Logg.Debug( new { request = request.Uri.ToString(), token = "upgrade", from = currentExpire, to = resultExpire } .stringify()); } var result = BuildIdentity(token); return(result); }
public string GetSalt(string username, IScope context = null) { if (string.IsNullOrWhiteSpace(username)) { throw new ArgumentException("username"); } var opid = GETSALTOPID + Interlocked.Increment(ref logonid); if (Logg.IsForDebug()) { Logg.Debug(new { opid, username, context }); } string result = null; var securelogon = Extensions.OfType <ISecureLogon>().FirstOrDefault(); if (null == securelogon) { if (Logg.IsForError()) { Logg.Error(new { opid, message = "not secure login confugured" }.stringify()); } } else { result = securelogon.GetSalt(username); } if (Logg.IsForDebug()) { Logg.Debug(new { opid, username, salt = result }.stringify()); } return(result); }
private IIdentity ResolveByExtensions(string username, string password, string opid, IScope context) { var extensions = Extensions.OfType <IPasswordLogon>().ToArray(); IIdentity bestresult = null; foreach (var passwordLogon in extensions) { if (Logg.IsForDebug()) { Logg.Debug(new { opid, ext = passwordLogon.GetType().Name, message = "enter" }.stringify()); } var subresult = passwordLogon.Logon(username, password, context); if (Logg.IsForDebug()) { Logg.Debug(new { opid, ext = passwordLogon.GetType().Name, message = null != subresult && subresult.IsAuthenticated }.stringify()); } if (null != subresult && UserActivityState.None != ((Identity)subresult).State) { bestresult = subresult; } if (null != subresult && subresult.IsAuthenticated) { return(subresult); } } return(bestresult); }
public int actualizarCompra(CL_Compra p_compr) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = string.Format("UPDATE COMPRA SET fechaCompra = '{0}'" + ", idUsuario={1} WHERE idCompra={2}" , p_compr.FechaCompra, p_compr.UsuarioCompra.IdUsuario, p_compr.IdCompra); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
public int agregarCompra(CL_Compra p_compr) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = string.Format("INSERT INTO COMPRA(fechaCompra,idUsuario)" + " VALUES('{0}',{1})" , p_compr.FechaCompra, p_compr.UsuarioCompra.IdUsuario); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
public int maxId() { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "SELECT max(idCompra) as MAX FROM compra ;"; cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { resp = Convert.ToInt32(dr["MAX"].ToString()); } } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
public JegerSelectorVM(int jaktId, List <int> jegerIds, Logg currentLogg = null) { JaktId = jaktId; JegerIds = jegerIds; CurrentLogg = currentLogg; GroupedItems = new ObservableRangeCollection <JegerSelectorGroup>(); }
private void LogStart(string username, SecureLogonInfo info, IScope context, string opid) { if (Logg.IsForDebug()) { Logg.Debug(new { opid, username, salt = info.Salt, sign = info.Sign, context }.stringify()); } }
public int agregarDetalleCompra(CL_DetalleCompra p_detalle) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = string.Format("INSERT INTO DETALLECOMPRA(idCompra,idProducto,Cantidad)" + " VALUES({0},{1},{2})" , p_detalle.Compra.IdCompra, p_detalle.Producto.IdProducto, p_detalle.Cantidad); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
public int agregarProducto(CL_Producto p_prod) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = string.Format("INSERT INTO PRODUCTO(NombreProducto,PrecioProducto,EsCombo,DiaCombo,stock,habilitado)" + " VALUES('{0}',{1},'{2}','{3}',{4},'{5}')" , p_prod.NombreProducto, p_prod.PrecioProducto, p_prod.EsCombo, p_prod.DiaCombo, p_prod.Stock, p_prod.Habilitado); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
protected void btn_actualizar_Click(object sender, EventArgs e) { try { CL_Producto aux_pro = serv.productoListar().Where(x => x.NombreProducto == ddl_producto.SelectedItem.Text).First(); aux_pro.PrecioProducto = Convert.ToInt32(txt_precio.Text); aux_pro.Stock = Convert.ToInt32(txt_stock.Text); string dia = Convert.ToDateTime(aux_pro.DiaCombo).ToString("yyyy-MM-dd"); aux_pro.DiaCombo = dia; if (rb_si.Checked) { aux_pro.Habilitado = "HABILITADO"; } else { aux_pro.Habilitado = "DESHABILITADO"; } string xmlProducto = SerializeProducto <CL_Producto>(aux_pro); bool resp = serv.productoActualizar(xmlProducto); if (resp) { lbl_mensaje.Text = "Producto Actualizado"; } } catch (Exception ex) { Logg.Mensaje(ex.Message); } }
public int actualizarProducto(CL_Producto p_pro) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = string.Format("UPDATE PRODUCTO SET NombreProducto = '{0}'" + ", PrecioProducto={1} , EsCombo ='{2}' , DiaCombo = '{3}' , stock={4} ,habilitado = '{5}' WHERE idProducto = {6}" , p_pro.NombreProducto, p_pro.PrecioProducto, p_pro.EsCombo, p_pro.DiaCombo, p_pro.Stock, p_pro.Habilitado, p_pro.IdProducto); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
public int eliminarUsuario(int id) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "UPDATE USUARIO SET habilitado='DESHABILITADO' WHERE idUsuario =" + id + ""; cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
void DestinationClient_DataReceived(object sender, Client.DataReceivedEventArgs e) { NetworkMessage message = ProtocolManager.GetPacket(e.Data.Data, (uint)e.Data.MessageId); Host.Dispatcher.DispatchMessage(message, Host); Logg.Log("From server :" + message.MessageId.ToString()); }
public int agregarUsuario(CL_Usuario p_user) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "INSERT INTO USUARIO(Nombre,Apellido,Password,TipoUsuario,user,local,habilitado) " + "VALUES('" + p_user.Nombre + "','" + p_user.Apellido + "','" + p_user.Password + "','" + p_user.TipoUsuario + "','" + p_user.User + "','" + p_user.Local + "','HABILITADO'" + ")"; cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
public int actualizarDetalleCompraCantidad(CL_DetalleCompra p_detalle) { int resp = 0; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = string.Format("UPDATE DETALLECOMPRA SET " + "Cantidad = {0} WHERE idCompra = {1} and idProducto = {2}" , p_detalle.Cantidad, p_detalle.Compra.IdCompra, p_detalle.Producto.IdProducto); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = cone; if (cone.State != System.Data.ConnectionState.Open) { cone.Open(); } resp = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logg.Mensaje(ex.Message); if (cone.State != System.Data.ConnectionState.Closed) { cone.Close(); } ; return(0); } return(resp); }
protected void btn_agregar_Click(object sender, EventArgs e) { try { if (Session["tablaCompra"] == null) { aux_table = new DataTable(); aux_table.Columns.Add("ID"); aux_table.Columns.Add("Nombre Producto"); aux_table.Columns.Add("Precio"); aux_table.Columns.Add("Cantidad"); } else { aux_table = (DataTable)Session["tablaCompra"]; } DataRow dr = aux_table.NewRow(); dr["ID"] = DropDownList1.SelectedValue; dr["Nombre Producto"] = DropDownList1.SelectedItem.Text; dr["Precio"] = lbl_precio.Text; dr["Cantidad"] = DropDownList2.SelectedItem.Text; aux_table.Rows.Add(dr); Session["tablaCompra"] = aux_table; gv_carro.DataSource = aux_table; gv_carro.DataBind(); } catch (Exception ex) { Logg.Mensaje(ex.Message); } }
public DogSelectorVM(int jaktId, List <int> dogIds, Logg currentLogg = null) { JaktId = jaktId; DogIds = dogIds; CurrentLogg = currentLogg; GroupedItems = new ObservableRangeCollection <DogSelectorGroup>(); }
protected void btn_grabar_Click(object sender, EventArgs e) { try { CL_Usuario user = new CL_Usuario(); user.Nombre = txt_nombre.Text; user.Apellido = txt_apellido.Text; user.Local = ddl_local.SelectedValue; user.Habilitado = "HABILITADO"; user.Password = "******"; user.TipoUsuario = "Personal"; string xmlUser = SerializeUser <CL_Usuario>(user); bool resp = serv.usuarioGrabarXML(xmlUser); if (resp) { lbl_mensaje.Text = "Usuario Agregado"; } else { lbl_mensaje.Text = "Usuario No Agregado"; } } catch (Exception ex) { Logg.Mensaje(ex.Message); } }
protected Logg CreateLogDto() { var log = new Logg(); log.ID = ID ?? Guid.NewGuid().ToString(); log.JaktId = HuntId; log.Sett = Observed; // int.Parse(ObservedPickers.SingleOrDefault(h => h.Selected)?.ID ?? "0"); log.Skudd = Shots; // int.Parse(ShotsPickers.SingleOrDefault(h => h.Selected)?.ID ?? "0"); log.Treff = Hits; // int.Parse(HitsPickers.SingleOrDefault(h => h.Selected)?.ID ?? "0"); log.Dato = Date; log.Latitude = Position.Latitude.ToString(); log.Longitude = Position.Longitude.ToString(); log.Notes = Notes; log.JegerId = HuntersPickers.SingleOrDefault(h => h.Selected)?.ID; log.DogId = DogsPickers.SingleOrDefault(h => h.Selected)?.ID; log.ArtId = SpeciesPickers.SingleOrDefault(h => h.Selected)?.ID; log.Age = Age; log.ButchWeight = ButchWeight; log.Gender = Gender; log.Weather = Weather; log.WeaponType = WeaponType; log.Weight = Weight; log.Tags = Tags; return(log); }
public DogSelectorPage(int jaktId, List <int> dogIds, Logg currentLogg = null) { BindingContext = VM = new DogSelectorVM(jaktId, dogIds, currentLogg); ToolbarItems.Add(new ToolbarItem("+", "add.png", () => { Navigation.PushAsync(new DogPage(new Dog()), true); }, ToolbarItemOrder.Primary)); }
public void SimpleMethod() { Logg.Info(GetType().Name); Logg.Info("Process start"); Repo.TestRepository1(); Logg.Info($@"Repo out - {Repo.TestRepository2()}"); Logg.Debug("Process stopped"); }
public void BeforeNavigate(Logg dto, Jakt huntDto) { _huntDto = huntDto; _dto = dto ?? CreateItem(); SetState(_dto); Title = IsNew ? "Ny loggføring" : dto.Dato.ToShortTimeString(); }