Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
 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;
 }
Пример #5
0
        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 });
        }
Пример #6
0
        //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);
        }
Пример #7
0
 private void LogStart(string username, string password, IScope context, string opid)
 {
     if (Logg.IsForDebug())
     {
         Logg.Debug(new { opid, username, pass = password.GetMd5(), context }.stringify());
     }
 }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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>();
 }
Пример #15
0
 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());
     }
 }
Пример #16
0
        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);
        }
Пример #17
0
        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);
            }
        }
Пример #19
0
        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);
        }
Пример #20
0
        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);
        }
Пример #21
0
        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());
        }
Пример #22
0
        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);
        }
Пример #23
0
        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);
        }
Пример #24
0
        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);
            }
        }
Пример #25
0
 public DogSelectorVM(int jaktId, List <int> dogIds, Logg currentLogg = null)
 {
     JaktId       = jaktId;
     DogIds       = dogIds;
     CurrentLogg  = currentLogg;
     GroupedItems = new ObservableRangeCollection <DogSelectorGroup>();
 }
Пример #26
0
        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);
            }
        }
Пример #27
0
        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);
        }
Пример #28
0
 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");
 }
Пример #30
0
        public void BeforeNavigate(Logg dto, Jakt huntDto)
        {
            _huntDto = huntDto;
            _dto     = dto ?? CreateItem();

            SetState(_dto);
            Title = IsNew ? "Ny loggføring" : dto.Dato.ToShortTimeString();
        }