Exemplo n.º 1
0
        public void MapperTest_ToDataObjects()
        {
            Client client = new Client("Test name", "Test addres");

            DClient dClient = Mapper.ToDClient(client);

            dClient.Id.Should().Be(client.Id);
            dClient.Addres.Should().Be(client.Addres);
            dClient.Name.Should().Be(client.Name);
            dClient.Orders.Count.Should().Be(0);

            Order order = new Order(ProductType.Duvel, 5, client);

            DOrder dOrder = Mapper.ToDOrder(order);

            dOrder.Id.Should().Be(order.Id);
            dOrder.Product.Should().Be(order.Product);
            dOrder.Amount.Should().Be(order.Amount);

            client.AddOrder(ProductType.Leffe, 10);

            dClient = Mapper.ToDClient(client);
            dClient.Orders.Count.Should().Be(1);
            dClient.Orders[0].Id.Should().Be(client.Orders[0].Id);
            dClient.Orders[0].Product.Should().Be(client.Orders[0].Product);
            dClient.Orders[0].Amount.Should().Be(client.Orders[0].Amount);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutDCandidate(int id, DClient dClient)
        {
            /*
             * if (id != dCandidate.Id)
             * {
             *  return BadRequest();
             * }
             */
            dClient.Id = id;

            _context.Entry(dClient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DClientsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        private DClient Conection(string host, int port, string login, string password)
        {
            this.Dispatcher.Invoke(delegate() {
                btnLogin.IsEnabled   = false;
                prgStatus.Visibility = Visibility.Visible;
            });

            DClient cl = new DClient(host, port);

            try
            {
                if (!cl.InitConnection())
                {
                    MessageBox.Show("Не удалось соединиться с сервером");
                    return(null);
                }
                cl.SignIn(login, password);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(cl);
            }
            return(cl);
        }
Exemplo n.º 4
0
        public void MapperTest_ToDomainObjects()
        {
            DClient dClient = new DClient("Test", "Test address");

            Client client = Mapper.ToClient(dClient);

            client.Id.Should().Be(dClient.Id);
            client.Addres.Should().Be(dClient.Addres);
            client.Name.Should().Be(dClient.Name);
            client.Orders.Count.Should().Be(0);

            DOrder dOrder = new DOrder(ProductType.Duvel, 10);

            Order order = Mapper.ToOrder(dOrder, client);

            order.Id.Should().Be(dOrder.Id);
            order.Product.Should().Be(dOrder.Product);
            order.Amount.Should().Be(dOrder.Amount);
            order.Client.Id.Should().Be(client.Id);
            order.Client.Addres.Should().Be(client.Addres);
            order.Client.Name.Should().Be(client.Name);
            order.Client.Orders.Count.Should().Be(0);

            client.AddOrder(ProductType.Leffe, 6);

            Client client2 = Mapper.ToClient(Mapper.ToDClient(client));

            client2.Id.Should().Be(client.Id);
            client2.Addres.Should().Be(client.Addres);
            client2.Name.Should().Be(client.Name);
            client2.Orders.Count.Should().Be(1);
            client2.Orders[0].Id.Should().Be(client.Orders[0].Id);
            client2.Orders[0].Product.Should().Be(client.Orders[0].Product);
            client2.Orders[0].Amount.Should().Be(client.Orders[0].Amount);
        }
Exemplo n.º 5
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            NetState[] states = NetState.Instances.ToArray();

            for (int i = 0; i < states.Length; i++)
            {
                if (states[i].IsDisposing || !states[i].Running || states[i].Mobile == null ||
                    !states[i].Mobile.Name.Equals(args.Parameters[0], StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                string reason = args.Parameters.Count > 1 ? args.Parameters[1] : "unspecified";

                states[i].Mobile.SendMessage($"You have been banned for: {reason}");
                states[i].Mobile.Account.Banned = true;
                states[i].Dispose();

                DClient.DiscordLog($"{args.User.Username} banned player {args.Parameters[0]} for reason: {reason}", LogLevel.Info);
                args.Channel.SendEmbedMessage($"Banned player {args.Parameters[0]} for reason: {reason}").ConfigureAwait(false);
                return;
            }

            args.Channel.SendEmbedMessage($"Player {args.Parameters[0]} not found").ConfigureAwait(false);
        }
        public SettingsView(Settings set, DClient client, int?id = null)
        {
            this.client = client;
            settings    = set;
            InitializeComponent();

            lblVersion.Content = ABShared.ProjectVersion.Version.ToString();
            this.DataContext   = settings;

            try
            {
                txtLince.Text = File.ReadAllText(Environment.CurrentDirectory + @"/ProgramData/Lince.txt");
                userAgents    = File.ReadAllLines(@"Data\UserAgentsList.txt").ToList();
                userAgents.Insert(0, settings.UserAgent);
                cmbUserAgents.ItemsSource = userAgents;
                lvBookmakes.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка загруки. " + ex.Message);
            }

            if (id != null)
            {
                tbcTabs.SelectedIndex     = 1;
                lvBookmakes.SelectedIndex = (int)id;
            }

            client.GetLeftDays += Client_GetLeftDays;
            client.GetSiteData += Client_GetSiteData;
            this.Loaded        += SettingsView_Loaded;
        }
        public static DataTable BuscarNum_Documento(string textobuscar)
        {
            DClient Obj = new DClient();

            Obj.TextoBuscar = textobuscar;
            return(Obj.BuscarNum_Documento(Obj));
        }
        //Método Eliminar que llama al método Eliminar de la clase DCliente
        //de la CapaDatos
        public static string Eliminar(int idcliente)
        {
            DClient Obj = new DClient();

            Obj.Idcliente = idcliente;
            return(Obj.Eliminar(Obj));
        }
Exemplo n.º 9
0
        public async Task <ActionResult <DClient> > PostDCandidate(DClient dClient)
        {
            _context.DClients.Add(dClient);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDClient", new { id = dClient.Id }, dClient));
        }
Exemplo n.º 10
0
        void RegisterCommand(ICommand cmd)
        {
            string cmdName = cmd.Command.ToLower();

            if (_commands.ContainsKey(cmdName))
            {
                DClient.WriteLine($"Discord: Command {cmdName} already exists, skipping...");
                return;
            }

            for (int i = 0; i < cmdName.Length; i++)
            {
                if (cmdName[i] == ' ')
                {
                    DClient.WriteLine($"Discord: Command {cmdName} contains illegal character \" \", skipping...");
                    return;
                }
                else if (!char.IsLetterOrDigit(cmdName[i]))
                {
                    DClient.WriteLine($"Discord: Command {cmdName} contains illegal character \"{cmdName[i]}\", skipping...");
                    return;
                }
            }

            _commands.Add(cmdName, cmd);
            DClient.WriteLine($"Discord: Registered command {cmdName}");
        }
Exemplo n.º 11
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            DClient.DiscordLog($"{args.User.Username} started a world save", LogLevel.Info);

            args.Channel.SendEmbedMessage("Saving the world...").ConfigureAwait(false).GetAwaiter().GetResult();
            World.Save();
            args.Channel.SendEmbedMessage("World was saved...").ConfigureAwait(false);
        }
Exemplo n.º 12
0
        public static DataTable SearchDocument(string searchtext)
        {
            DClient Obj = new DClient();

            Obj.SearchText = searchtext;

            return(Obj.SearchDocument(Obj));
        }
Exemplo n.º 13
0
        public static string Delete(int id)
        {
            DClient Obj = new DClient();

            Obj.Id = id;


            return(Obj.Delete(Obj));
        }
Exemplo n.º 14
0
        public MainViewModel(DClient client)
        {
            _client = client;
            // client.GetData += Client_GetData;
            StretchCommand = new ReallyCommand(StretchingExecute);

            // Инстализируем отдельный поток для обновления вилок
            //_thForksUpdate = new Thread(ForksUpdate) {IsBackground = true};
            //_thForksUpdate.Start();
        }
Exemplo n.º 15
0
        public void AddClient(Client client)
        {
            DClient toAdd = Mapper.ToDClient(client);

            if (context.Clients.AsNoTracking().Any(c => c.Name == toAdd.Name && c.Addres == toAdd.Addres))
            {
                throw new DataException("Client is al in databank.");
            }
            context.Clients.Add(toAdd);
        }
Exemplo n.º 16
0
        public void AddClient(Client client)
        {
            //mag nog niet in databank zitten
            DClient dClient = Mapper.FromClientToDClient(client);

            if (context.Clients.Any(c => c.Name == client.Name && c.Address == client.Address))
            {
                throw new Exception("Client already in database.");
            }
            //klant toevoegen
            context.Clients.Add(dClient);
        }
        //Métodos para comunicarnos con la capa datos
        //Método Insertar que llama al método Insertar de la clase DCliente
        //de la CapaDatos
        public static string Insertar(string nombreya, string tipo_documento, string num_documento,
                                      string direccion, string telefono)
        {
            DClient Obj = new DClient();

            Obj.Nombreya       = nombreya;
            Obj.Tipo_Documento = tipo_documento;
            Obj.Num_Documento  = num_documento;
            Obj.Direccion      = direccion;
            Obj.Telefono       = telefono;
            return(Obj.Insertar(Obj));
        }
Exemplo n.º 18
0
        public void UpdateClient(Client client)
        {
            if (!context.Clients.Any(c => c.ClientId == client.Id))
            {
                throw new Exception("Client not in database");
            }
            DClient clientToUpdate = context.Clients
                                     .Include(c => c.Orders)
                                     .Single(c => c.ClientId == client.Id);

            clientToUpdate.Address = client.Address;
            clientToUpdate.Name    = client.Name;
        }
Exemplo n.º 19
0
 // Enregistre le client id dans la BDD
 internal bool SaveClient(Client c)
 {
     try
     {
         DClient.Add(c);
         SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 20
0
        /// <summary>
        /// Maps Data Client object to Client object
        /// </summary>
        /// <param name="dclient">=Data Client to map</param>
        /// <returns></returns>
        public static Client FromDClientToClient(DClient dclient)
        {
            Client client = new Client(dclient.Name, dclient.Address);

            client.Id = dclient.ClientId;
            foreach (DOrder dOrder in dclient.Orders)
            {
                Order toAdd = new Order(dOrder.Product, dOrder.Amount, client);
                toAdd.Id = dOrder.OrderId;
                client.AddOrder(toAdd);
            }
            return(client);
        }
Exemplo n.º 21
0
        public Client GetClient(string Name, string Address)
        {
            if (!context.Clients.Any(c => c.Name == Name && c.Address == Address))
            {
                throw new Exception("Client not in database.");
            }

            DClient dclient = context.Clients
                              .AsNoTracking()
                              .Include(c => c.Orders)
                              .AsNoTracking()
                              .Single(c => c.Name == Name && c.Address == Address);

            return(Mapper.FromDClientToClient(dclient));
        }
Exemplo n.º 22
0
        public Client GetClient(int id)
        {
            //kijk of het erinzit
            if (!context.Clients.Any(c => c.ClientId == id))
            {
                throw new Exception("Client not in database");
            }
            DClient dclient = context.Clients
                              .AsNoTracking()
                              .Include(c => c.Orders)
                              .AsNoTracking()
                              .Single(c => c.ClientId == id);

            return(Mapper.FromDClientToClient(dclient));
        }
Exemplo n.º 23
0
 // Enregistre le tel id dans la BDD
 internal bool SaveAdresse(Adresse adressebol)
 {
     try
     {
         adressebol.IdClient = DClient.Select(c => c.Id).Max();
         if (adressebol != null)
         {
             DAdresse.Add(adressebol);
         }
         SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 24
0
 // Enregistre le telephone id dans la BDD
 internal bool SaveTelephone(Telephone tele)
 {
     try
     {
         if (tele.IdClient == 0)
         {
             tele.IdClient = DClient.Select(c => c.Id).Max();
         }
         DTelephone.Add(tele);
         SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 25
0
        // Suppruime le client dans la BDD
        internal void SupprimeClient(int id)
        {
            try// faudra effacer les adresse, num tel etc, Ssi !!!! pas de reservation
            {
                Client c = DClient.Find(id);
                if (c != null)
                {
                    //Enleve l'adresse reliée
                    Adresse a = DAdresse.Find(c.Id);
                    if (a != null)
                    {
                        DAdresse.Remove(a);
                    }

                    //Enleve les telephones reliées
                    List <Telephone> tel = DTelephone.Where(t => t.IdClient == id).ToList();
                    if (tel != null)
                    {
                        foreach (var t in tel)
                        {
                            DTelephone.Remove(t);
                        }
                    }

                    //Enleve les telephones reliées
                    List <Email> email = DEmail.Where(t => t.IdClient == id).ToList();
                    if (email != null)
                    {
                        foreach (var t in email)
                        {
                            DEmail.Remove(t);
                        }
                    }


                    DClient.Remove(c);

                    SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 26
0
        public static string Insert(string name, string surname, string gender, DateTime dob,
                                    string document_type, string document_number, string address, string phone, string email)
        {
            DClient Obj = new DClient();

            Obj.Name           = name;
            Obj.Surname        = surname;
            Obj.Gender         = gender;
            Obj.Dob            = dob;
            Obj.TypeDocument   = document_type;
            Obj.DocumentNumber = document_number;
            Obj.Address        = address;
            Obj.Phone          = phone;
            Obj.Email          = email;


            return(Obj.Insert(Obj));
        }
Exemplo n.º 27
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            if (DClient.UserManager[args.User.Id] != null)
            {
                args.Channel.SendEmbedMessage("You already linked your account!").ConfigureAwait(false);
                return;
            }

            var dmChannel = DClient.GetDmChanelAsync(args.User.Id).ConfigureAwait(false).GetAwaiter().GetResult();

            if (_verificationUsers.TryGetValue(args.User.Id, out string verCode))
            {
                if (dmChannel == null)
                {
                    args.Channel.SendEmbedMessage("Verification code already created").ConfigureAwait(false);
                    return;
                }

                dmChannel.SendEmbedMessage($"Verification code already created: {verCode}").ConfigureAwait(false);
                return;
            }

            if (dmChannel == null)
            {
                args.Channel.SendEmbedMessage("Unable to open direct message channel").ConfigureAwait(false);
                return;
            }

            verCode = GenerateCode(Utility.Random(6, 4));
            _verificationCodes.TryAdd(verCode, args.User.Id);
            _verificationUsers.TryAdd(args.User.Id, verCode);

            dmChannel.SendEmbedMessage($"Verification code created, login onto any of your characters (in UO) and type the following (Code is Case-Sensitive): [linkaccount {verCode}").ConfigureAwait(false);

            if (args.Guild != null)
            {
                args.Message.DeleteAsync().ConfigureAwait(false);
            }
        }
Exemplo n.º 28
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            DiscordUserLink dul = DClient.UserManager[args.User.Id];

            if (dul != null && dul.Accounts != null && dul.Accounts.Length >= DClient.UserManager.AccountsPerIp)
            {
                args.Channel.SendEmbedMessage("You can't create more accounts").ConfigureAwait(false);
                return;
            }
            else if (dul == null)
            {
                dul = new DiscordUserLink(args.User.Id);
            }

            Account acc = new Account(args.Parameters[0], args.Parameters[1]);

            dul.AddAccount(acc);
            DClient.UserManager.AddOrUpdate(dul);

            args.Channel.SendEmbedMessage($"Created account:\n```\n{args.Parameters[0]}\n{args.Parameters[1]}\n```").ConfigureAwait(false);
            DClient.DiscordLog($"New account created: {args.Parameters[0]}", LogLevel.Info);
        }
Exemplo n.º 29
0
        public void InitCommands()
        {
            if (_commands.Count > 0)
            {
                _commands.Clear();
            }

            Assembly ass = typeof(CommandHandler).Assembly;

            Type[] types = ass.GetTypes();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].GetCustomAttribute <CommandAttribute>() == null)
                {
                    continue;
                }

                ICommand cmd;
                try
                {
                    cmd = Activator.CreateInstance(types[i]) as ICommand;
                }
                catch (Exception ex)
                {
                    DClient.Error("Command Initialization", ex.ToString());
                    continue;
                }

                if (cmd == null)
                {
                    continue;
                }

                RegisterCommand(cmd);
            }

            DClient.WriteLine($"Registered a total of {_commands.Count} commands");
        }
        public async Task <IActionResult> PutDClient(int id, DClient dClient)
        {
            dClient.ClientID = id;

            _context.Entry(dClient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DClientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }