Пример #1
0
        public async Task <bool> Delete(int id, IAccess cs)
        {
            Proxy proxy = new Proxy(cs);

            using (NpgsqlConnection conn = new NpgsqlConnection(proxy.ConnectionString))
            {
                try
                {
                    conn.Open();
                    using (NpgsqlCommand cmd = new NpgsqlCommand("select * from st_delete(:clave)", conn))
                    {
                        cmd.Parameters.AddWithValue("clave", id);
                        if ((int)cmd.ExecuteScalar() == 1)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    conn.Close();
                    return(false);
                }
            }
        }
Пример #2
0
        public async Task <bool> Create(IEmpleado emp, IAccess cs)
        {
            Proxy proxy = new Proxy(cs);

            using (NpgsqlConnection conn = new NpgsqlConnection(proxy.ConnectionString))
            {
                try
                {
                    conn.Open();
                    using (NpgsqlCommand cmd = new NpgsqlCommand("select * from st_insert(:_nombre,:_apellido,:_email)", conn))
                    {
                        cmd.Parameters.AddWithValue("_nombre", emp.Nombre);
                        cmd.Parameters.AddWithValue("_apellido", emp.Apellido);
                        cmd.Parameters.AddWithValue("_email", emp.Email);
                        if ((int)cmd.ExecuteScalar() == 1)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    conn.Close();
                    return(false);
                }
            }
        }
 public IAccess StartTransaction()
 {
     _transaction = _store.Client.StartSession();
     _transaction.StartTransaction();
     Access = new MongoDbAccess(_store);
     return(Access);
 }
Пример #4
0
        public async Task <IEmpleado> GetEmpleado(int id, IAccess cs)
        {
            Proxy    proxy = new Proxy(cs);
            Empleado emp   = new Empleado();

            using (NpgsqlConnection conn = new NpgsqlConnection(proxy.ConnectionString))
            {
                try
                {
                    conn.Open();
                    using (NpgsqlCommand cmd = new NpgsqlCommand($"select * from st_empleadoid(:clave)", conn))
                    {
                        cmd.Parameters.AddWithValue("clave", id);
                        using (NpgsqlDataReader pgreader = cmd.ExecuteReader())
                        {
                            while (pgreader.Read())
                            {//Crear el objeto
                                emp.Id       = int.Parse(pgreader["_id"].ToString());
                                emp.Nombre   = pgreader["_nombre"].ToString();
                                emp.Apellido = pgreader["_apellido"].ToString();
                                emp.Email    = pgreader["_email"].ToString();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    conn.Close();
                }
                conn.Close();
            }

            return(emp);
        }
Пример #5
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <string> GettingInfoAsync(this IAccess operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GettingInfoWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
        public ResultOutput Add(Training TData)
        {
            string       message = string.Empty;
            ResultOutput ROutput = new ResultOutput();

            DateTime startDateTime;
            DateTime endDateTime;

            startDateTime = Convert.ToDateTime(TData.StartDate);
            endDateTime   = Convert.ToDateTime(TData.EndDate);

            if (endDateTime > startDateTime)
            {
                TimeSpan ts = endDateTime - startDateTime;
                // Check if the training name exists - else proceed
                int count = IAccess.GetTrainingsByName(TData.Name).Count();
                if (count == 0)
                {
                    IAccess.Create(TData);
                    ROutput.isSuccess = true;
                    ROutput.Message   = "Training added successfully. The training is for " + ts.Days + " days.";
                }
                else
                {
                    ROutput.Message   = IConfig["ErrorCode1"].ToString();
                    ROutput.isSuccess = false;
                }
            }
            else
            {
                ROutput.Message   = IConfig["ErrorCode2"].ToString();
                ROutput.isSuccess = false;
            }
            return(ROutput);
        }
Пример #7
0
 /// <summary>
 /// Logins a User
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='loginEntity'>
 /// Entity for parametizing this action
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Responser> LoginAsync(this IAccess operations, AMLoginEntity loginEntity, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.LoginWithHttpMessagesAsync(loginEntity, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
        public IAccess StartTransaction()
        {
            _session = Store.OpenAsyncSession();
            Access   = new RavenDbAccess(_session);

            return(Access);
        }
Пример #9
0
 /// <summary>
 /// Logs Off a User
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// ID
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Responser> LogOffAsync(this IAccess operations, string id, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.LogOffWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #10
0
 /// <summary>
 /// Конструктор класса, инициализация всей автоматики персонажа
 /// </summary>
 /// <param name="form"> форма вывода инфрмации </param>
 /// <param name="access">реализация доступа к данным </param>
 public CPU(Form1 form, IAccess access) : base(form, access)
 {
     this.access = access;
     tm.Interval = speed;
     tm.Tick    += new EventHandler(Automatics);
     tm.Interval = 60;
     tm.Start();
 }
Пример #11
0
        /// <summary>
        /// Конструктор класса, запускает таймер(обновление обьекта пули)
        /// </summary>
        /// <param name="form">форма вывода графических данных</param>
        /// /// <param name="access">доступ к данным</param>
        public Bullet(Form1 form, IAccess access)
        {
            this.form   = form;
            this.access = access;

            timer.Interval = speed;
            timer.Tick    += new EventHandler(TimerFrames);
            timer.Start();
        }
Пример #12
0
 public GetCurrentUserQueryHandler(
     IAccess access,
     AppSettings appSettings,
     IUserRepository userRepo,
     ITenantRepository tenantRepo)
 {
     this.access      = access;
     this.appSettings = appSettings;
     this.userRepo    = userRepo;
     this.tenantRepo  = tenantRepo;
 }
Пример #13
0
        /// <summary> Enqueue access action into work queue with given <paramref name="priority" /> (if supported) </summary>
        /// <param name="queue"> Work queue instance </param>
        /// <param name="access"> Access action instance </param>
        /// <param name="priority"> Access action priority </param>
        /// <param name="cancellation"> Access cancellation token </param>
        /// <param name="attemptsCount"> Retry on fail attempts count </param>
        /// <typeparam name="TResource"> Shared resource type</typeparam>
        /// <returns> Access action completion task </returns>
        /// <exception cref="ArgumentNullException"> Thrown if <paramref name="access" /> or <paramref name="queue" /> is NULL </exception>
        public static Task EnqueueAccess <TResource>(this IWorkQueue queue, IAccess <TResource> access, CancellationToken cancellation = default,
                                                     int attemptsCount = 1, int priority = 0)
            where TResource : notnull
        {
            _ = access ?? throw new ArgumentNullException(nameof(access));
            var work = CreateAsyncWork((provider, cancel) => provider.EnqueueAccess(access, cancel, attemptsCount, priority));

            return((queue ?? throw new ArgumentNullException(nameof(queue))) is IPriorityWorkQueue priorityQueue
            ? priorityQueue.EnqueueAsyncWork(work, priority, cancellation)
            : queue.EnqueueAsyncWork(work, cancellation));
        }
        public static XElement GetAccess(this IAccess entity, string name = "access")
        {
            var urdmsUsers = from o in entity.UrdmsUsers
                             select new XElement("urdms-user", new XAttribute("user-id", o.Id), new XAttribute("full-name", o.Name), new XAttribute("role", ((AccessRole)o.Role).GetDescription()));

            var nonUrdmsUsers = from o in entity.NonUrdmsUsers
                                select new XElement("non-urdms-user", new XAttribute("full-name", o.Name), new XAttribute("role", ((AccessRole)o.Role).GetDescription()));

            return(new XElement(name,
                                new XElement("urdms-users", urdmsUsers),
                                new XElement("non-urdms-users", nonUrdmsUsers)));
        }
        public IActionResult GetAllTrainings()
        {
            string message = string.Empty;

            try
            {
                var results = IAccess.GetAllTrainings();
                return(StatusCode(StatusCodes.Status200OK, results));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new { message = ex.Message }));
            }
        }
Пример #16
0
 public Authentication
 (
     TempLogSession tempLog,
     UnverifiedUser unverifiedUser,
     IAccess access,
     IHashedPasswordFactory hashedPasswordFactory,
     CachedUserContext userContext
 )
 {
     this.tempLog               = tempLog;
     this.unverifiedUser        = unverifiedUser;
     this.access                = access;
     this.hashedPasswordFactory = hashedPasswordFactory;
     this.userContext           = userContext;
 }
Пример #17
0
        public Unit(Form1 form, IAccess access)
        {
            this.form   = form;
            this.access = access;

            #region Resourses
            imgRight = Image.FromFile("unitRight.png");
            imgLeft  = Image.FromFile("unitLeft.png");
            imgUp    = Image.FromFile("unitUp.png");
            imgDown  = Image.FromFile("unitDown.png");
            #endregion

            Create();
            HealthPoints();
        }
Пример #18
0
        private Authentication createAuthentication(IAccess access)
        {
            var tempLogSession        = sp.GetService <TempLogSession>();
            var unverifiedUser        = new UnverifiedUser(sp.GetService <AppFactory>());
            var hashedPasswordFactory = sp.GetService <IHashedPasswordFactory>();
            var userContext           = sp.GetService <CachedUserContext>();

            return(new Authentication
                   (
                       tempLogSession,
                       unverifiedUser,
                       access,
                       hashedPasswordFactory,
                       userContext
                   ));
        }
Пример #19
0
        static void Main(string[] args)
        {
            ChannelFactory <IAccess> channel = null;

            //
            // NOTE: Replace the string below with Address.ServiceAddress2 to utilize AccessService2.
            //
            string serviceAddressUsed = Address.ServiceAddress1;

            try
            {
                channel = new ChannelFactory <IAccess>(GetClientBinding(),
                                                       new EndpointAddress(new Uri(serviceAddressUsed),
                                                                           EndpointIdentity.CreateDnsIdentity("localhost")));
                IAccess client = channel.CreateChannel();
                (( IClientChannel )client).OperationTimeout = TimeSpan.MaxValue;

                Console.WriteLine("The client has started and is accessing the service hosted at address {0}.\n", serviceAddressUsed);
                client.Access(Address.PrintServiceAddress);

                Console.WriteLine("Press [Enter] to stop.\n");
                Console.ReadLine();
            }
            catch (MessageSecurityException)
            {
                Console.WriteLine("Message security exception. Possibly the STS issued an invalid UPN claim.");
                Console.WriteLine("Press [Enter] to stop.\n");
                Console.ReadLine();
            }
            finally
            {
                try
                {
                    if (channel != null)
                    {
                        channel.Close();
                    }
                }
                catch (CommunicationException)
                {
                }
                catch (TimeoutException)
                {
                }
            }
        }
 /// <summary> connect controllers and delegate event handlers. </summary>
 /// <param name="enable"> controls user interaction in view. </param>
 /// <param name="io"> current/size/search/enter/remove fields. </param>
 /// <param name="click"> add to eventhandlers, null to skip. </param>
 public virtual void Connect(Enable enable, IAccess[] io, SetClick[] click)
 {
     // connect controllers for i/o
       for (int n = controller.Length; --n >= 0; )
     controller[n].Connect(enable, io);
       // show current name and size
       io[0].Text = name[current];
       controller[current].doSize(null, null);
       // delegate event handlers
       if (click[0] != null) click[0]((sender, e) => {
     // advance controller, show name and size
     current = (current + 1) % controller.Length;
     io[0].Text = name[current];
     controller[current].doSize(null, null);
       });
       if (click[1] != null) click[1]((sender, e) => controller[current].doSearch(sender, e));
       if (click[2] != null) click[2]((sender, e) => controller[current].doEnter(sender, e));
       if (click[3] != null) click[3]((sender, e) => controller[current].doRemove(sender, e));
       if (click[4] != null) click[4]((sender, e) => controller[current].doSize(null, null));
 }
Пример #21
0
        public AccessFactory()
        {
            try
            {
                IAccess iAccess = null;
                if (!bInit)
                {
                    // prüft, ob Key bereits exestiert
                    if (!dict.ContainsKey("dataaccessuser"))
                    {
                        iAccess = new DataAccessUser();
                        dict.Add("dataaccessuser", iAccess);
                    }

                    if (!dict.ContainsKey("dataaccessspiel"))
                    {
                        iAccess = new DataAccessSpiel();
                        dict.Add("dataaccessspiel", iAccess);
                    }

                    if (!dict.ContainsKey("dataaccesskategorie"))
                    {
                        iAccess = new DataAccessKategorie();
                        dict.Add("dataaccesskategorie", iAccess);
                    }

                    if (!dict.ContainsKey("dataaccessfragenantworten"))
                    {
                        iAccess = new DataAccessFragenAntworten();
                        dict.Add("dataaccessfragenantworten", iAccess);
                    }
                }
            } catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Fehler!" + ex);
            }
        }
Пример #22
0
        public async Task <List <IEmpleado> > GetAll(IAccess cs)
        {
            List <IEmpleado> lista = new List <IEmpleado>();
            Proxy            proxy = new Proxy(cs);

            using (NpgsqlConnection conn = new NpgsqlConnection(proxy.ConnectionString))
            {
                try
                {
                    conn.Open();
                    using (NpgsqlCommand cmd = new NpgsqlCommand("select * from st_empleados()", conn))
                    {
                        //cmd.CommandType = CommandType.StoredProcedure;

                        using (NpgsqlDataReader pgreader = cmd.ExecuteReader())
                        {
                            while (pgreader.Read())
                            {//Crear el objeto
                                Empleado emp = new Empleado();
                                emp.Id       = int.Parse(pgreader["_id"].ToString());
                                emp.Nombre   = pgreader["_nombre"].ToString();
                                emp.Apellido = pgreader["_apellido"].ToString();
                                emp.Email    = pgreader["_email"].ToString();
                                lista.Add(emp);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    conn.Close();
                }
                conn.Close();
            }
            return(lista);
        }
Пример #23
0
 /// <summary>
 /// Logs Off a User
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// ID
 /// </param>
 public static Responser LogOff(this IAccess operations, string id)
 {
     return(Task.Factory.StartNew(s => ((IAccess)s).LogOffAsync(id), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
        public AccessWrapper(IAccess access)
        {
            if (access == null)
                return;

            AccessLevel = access.AccessLevel;
            ValidThrough = access.ValidThrough;
            IsInheritable = access.IsInheritable;
            IsInherited = access.IsInherited;
        }
Пример #25
0
 /// <summary>
 /// Logins a User
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='loginEntity'>
 /// Entity for parametizing this action
 /// </param>
 public static Responser Login(this IAccess operations, AMLoginEntity loginEntity)
 {
     return(Task.Factory.StartNew(s => ((IAccess)s).LoginAsync(loginEntity), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary> safely return the first line of a <c>IAccess</c>. </summary>
 protected virtual string[] first(IAccess[] io, int offset)
 {
     string[] result = new string[io.Length - offset];
       for (int n = offset; n < io.Length; ++n)
     if (io[n] != null && io[n].Text != null) { // map null to null
       string s = io[n].Text.Trim();
       if (s.Length != 0) // map empty to null
     result[n - offset] = s.Contains("\n")
       ? s.Substring(0, s.IndexOf('\n')).Trim() // first line
       : s; // entire line
     }
       return result;
 }
Пример #27
0
 public RewardsBL(IAccess <Reward> obj)
 {
     _rewards = obj;
 }
Пример #28
0
 /// <summary> Enqueue access action into registered access queue with giver <paramref name="priority" /> (if supported) </summary>
 /// <param name="provider"> Service provider instance </param>
 /// <param name="access"> Access action instance </param>
 /// <param name="cancellation"> Access action cancellation token </param>
 /// <param name="attemptsCount"> Retry on fail attempts count </param>
 /// <param name="priority"> Access action priority </param>
 /// <typeparam name="TResource"> Shared resource type </typeparam>
 /// <typeparam name="TResult"> Access action result type </typeparam>
 /// <returns> Access action result task </returns>
 /// <exception cref="InvalidOperationException"> Thrown if no access queue for <typeparamref name="TResource" /> is registered </exception>
 /// <exception cref="ArgumentNullException"> Thrown if <paramref name="access" /> or <paramref name="provider" /> is NULL </exception>
 /// <seealso cref="IPriorityAccessQueue{TResource}.EnqueueAccess{TResult}(IAccess{TResource, TResult}, int, CancellationToken, int)" />
 public static Task <TResult> EnqueueAccess <TResource, TResult>(this IServiceProvider provider, IAccess <TResource, TResult> access,
                                                                 CancellationToken cancellation = default, int attemptsCount = 1, int priority = 0)
     where TResource : notnull
 => (provider ?? throw new ArgumentNullException(nameof(provider))).Service <IPriorityAccessQueue <TResource> >()
Пример #29
0
 public Proxy(IAccess cs)
 {
     ConnectionString = $"Server={cs.Source};Port={cs.Port}; User Id={cs.User};Password={cs.Password};Database ={cs.Catalog}; CommandTimeout=900;";
     //"Server=localhost;Port=5432; User Id=postgres;Password=1234;Database = systemBD"
     //ConnectionString = $"Data Source={ cs.Source};Initial Catalog={cs.Catalog};Persist Security Info=True;User Id={cs.User}; Password={cs.Password}";
 }
 /// <summary> create and connect controllers. </summary>
 /// <param name="enable"> controls user interaction in view. </param>
 /// <param name="io"> current/size/search/enter/remove fields. </param>
 /// <param name="click"> add to eventhandlers, null to skip. </param>
 /// <param name="bg"> for sequential background execution. </param>
 /// <param name="nameModel"> one or more name/db model pairs. </param>
 public Switcher(Enable enable, IAccess[] io, SetClick[] click, WorkQueue bg, params object[] nameModel)
     : this(bg, nameModel)
 {
     Connect(enable, io, click);
 }
Пример #31
0
 public bool IsAllowed(IAccess access)
 {
     return(IsAllowed(access.Tags));
 }
Пример #32
0
 public void ClientCode(IAccess access)
 {
     access.Request();
 }
Пример #33
0
    public Access()
    {
        FileAccess fa = new FileAccess();

        accessBehavior = fa;
    }
Пример #34
0
 public SecurityProvider()
 {
     _hashInstance = Hash.Instance;
     _saltInstance = Salt.Instance;
     _access       = new TokenAccess();
 }
 public BaseAccess(IAccess access)
 {
     _access = access;
 }