Example #1
0
            public static void Listen()
            {
                manager = new ClientManager();
                if (listener != null && accept)
                {
                    // Continue listening.
                    while (work)
                    {
                        Console.WriteLine("Waiting for client...");
                        try
                        {
                            var clientTask = listener.AcceptTcpClientAsync(); // Get the client

                            if (clientTask.Result != null)
                            {
                                Console.WriteLine("Client connected. Waiting for data.");
                                var client = clientTask.Result;

                                manager.AddClient(client);
                            }
                        }
                        catch (Exception e)
                        {
                            continue;
                        }
                    }
                }
            }
Example #2
0
        protected override void OnConnect(Event e)
        {
            Peer peer = e.Peer;
            uint id   = peer.ID + 1;           // Increase by 1 so ID of 0 remains free for host

            if (peer.IsSet)
            {
                NetworkLogger.Log($"Client [{id}] connected", LogCategory.Connections);

                var client = new FlareClientShell(peer)
                {
                    Id = id
                };
                ClientManager?.AddClient(client);

                // Send the client its ID manually
                PayloadHandler.AddCallback <ClientAssigned>(PushClientConnected);
                SendMessage(new IdAssignment {
                    id = id
                }, 0, peers: client.Peer);
            }
            else
            {
                NetworkLogger.Log("Unset peer connected. How?", LogCategory.Connections, LogLevel.Error);
            }
        }
        public DataErrResult BatchAddDevice([FromBody] List <DeviceInfo> devicesList)
        {
            var result = new DataErrResult();

            result.datas.AddRange(ClientManager.AddClient(devicesList));
            return(result);
        }
Example #4
0
        public void UpdateClientTelephoneCheck()
        {
            // arrange
            const int    idClient  = 1;
            const string firstname = "Jan";
            const string surname   = "Kowalski";
            const string telephone = "2132123133";
            const string pesel     = "2142421412421";

            const string newTelephone = "513312133";

            Client client = new Client(idClient, firstname, surname, telephone, pesel);

            ClientManager clientManager = new ClientManager();

            clientManager.AddClient(client);

            // act
            clientManager.UpdateClientTelephone(client, newTelephone);

            // assert
            Client updatedClient = clientManager.clients.Find(c => c.Pesel == pesel);

            Assert.AreEqual(newTelephone, updatedClient.TelephoneNumber);
        }
Example #5
0
        public async Task OnClientSave(object dataForm)
        {
            var dataFormLayout = dataForm as Syncfusion.XForms.DataForm.SfDataForm;
            var isValid        = dataFormLayout.Validate();

            dataFormLayout.Commit();
            if (!isValid)
            {
                await Application.Current.MainPage.DisplayAlert("Alert", "Please enter valid details", "Ok");

                return;
            }

            dataFormLayout.IsReadOnly = true;
            this.IsVisible            = false;

            var newClient = dataFormLayout.DataObject as NewClient;
            var client    = await ClientManager.AddClient(new Client
            {
                FullName = newClient.FullName,
                Email    = newClient.Email,
                Address  = newClient.Address,
                Phone    = newClient.Phone
            });

            await NavigationManager.NavigateToAsync <ClientViewModel>(client.ID).ConfigureAwait(false);
        }
Example #6
0
        public void AddClientParametrsTest()
        {
            // Arrange
            var clientRepositoryMock = Substitute.For <IClientRepository>();

            var sut = new ClientManager(clientRepositoryMock);

            Client client = new Client
            {
                Name        = "Martin Eden",
                PhoneNumber = "555-55-55",
                Balance     = (decimal)6021023
            };
            string  clientName        = "Martin Eden";
            string  clientPhoneNumber = "555-55-55";
            decimal clientBalance     = (decimal)6021023;

            // Act
            sut.AddClient(clientName, clientPhoneNumber, clientBalance);

            // Asserts
            clientRepositoryMock.Received(1).Insert(Arg.Is <Client>(c => c.Name == clientName &&
                                                                    c.PhoneNumber == clientPhoneNumber &&
                                                                    c.Balance == clientBalance));
        }
Example #7
0
 public void StartListening()
 {
     _listener.Start();
     while (true)
     {
         var client = _listener.AcceptTcpClient();
         _manager.AddClient(client);
     }
 }
Example #8
0
        private void SaveRecord()
        {
            var Address     = clientAddressTxt.Text;
            var Email       = clientEmailTxt.Text;
            var Name        = clientNameTxt.Text;
            var PhoneNumber = clientPhoneTxt.Text;

            clientManager.AddClient(Name, Address, PhoneNumber, Email);
            repositoryFactory.Save();
        }
        public Result AddDevice([FromBody] DeviceInfo deviceInfo)
        {
            var res    = ClientManager.AddClient(deviceInfo);
            var result = new Result
            {
                errno = res ? Error.Success : Error.DeviceIsExist
            };

            Log.DebugFormat("添加设备,{0},{1},{2}", deviceInfo.Ip, deviceInfo.Port, res);
            return(result);
        }
Example #10
0
        private void AcceptCallback(Socket server)
        {
            Socket connected_client = server.Accept();
            //ziskanie IP adresy
            string ip = ((IPEndPoint)(connected_client.RemoteEndPoint)).Address.ToString();

            Console.WriteLine("Connection accepted, IP: " + ip);
            //dummy ak nie je vlakno spracuvavajuce vstup do uzivatela zapnute zapni ho inak ignoruj
            mannager.AddClient(ip, connected_client);
            mannager.Start();
        }
        public void Initialize()
        {
            //
            // Generate the client manager and add a number of clients to the server.
            //

            clientManager = ClientManager.GetInstance();

            for (int i = 0; i < k_clientCount; i++)
            {
                var newClient = new Client(null);
                newClient.UserInfo.EmailAddress = "TestUser" + i.ToString();

                clientManager.AddClient(newClient);
            }
        }
Example #12
0
    private void InterpretMessage(string data)
    {
        Debug.Log(data);

        Dictionary <string, object> message = JsonConvert.DeserializeObject <Dictionary <string, object> >(data);

        int clientId = Convert.ToInt32(message["client_id"].ToString());

        clients.AddClient(clientId);

        if (message.ContainsKey("client_data"))
        {
            Dictionary <string, object> clientData = JsonConvert.DeserializeObject <Dictionary <string, object> >(message["client_data"].ToString());
            clients.UpdateClient(clientId, float.Parse(clientData["x"].ToString()), float.Parse(clientData["y"].ToString()));
        }
    }
Example #13
0
        public void AddClient(ClientViewModel clientViewModel)
        {
            try
            {
                tbl_Clients tblClient = new tbl_Clients();

                tblClient.ClientName  = clientViewModel.ClientName;
                tblClient.EntityState = DA.DomainModel.EntityState.Added;

                ClientManager clientManager = new ClientManager();

                clientManager.AddClient(tblClient);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #14
0
        private void SaveClient()
        {
            ErrorProvider.Clear();
            var isFormValid = true;

            if (txtName.Text.FullTrim().IsNullOrEmptyOrWhiteSpace())
            {
                isFormValid = false;
                ErrorProvider.SetError(txtName, Resources.ThisFieldIsRequired);
            }
            if (!isFormValid)
            {
                txtName.Focus();
                return;
            }
            if (!IsEditMode)
            {
                ClientManager.AddClient(new Client
                {
                    Name     = txtName.Text.FullTrim(),
                    Address  = txtAddress.Text.FullTrim(),
                    Phone    = txtPhone.Text.FullTrim(),
                    Email    = txtEmail.Text.FullTrim(),
                    Facebook = txtFacebook.Text.FullTrim(),
                    Viber    = txtViber.Text.FullTrim(),
                    WhatsApp = txtWhatsApp.Text.FullTrim(),
                    Other    = txtOther.Text.FullTrim()
                });
            }
            else
            {
                Client.Name     = txtName.Text.FullTrim();
                Client.Address  = txtAddress.Text.FullTrim();
                Client.Phone    = txtPhone.Text.FullTrim();
                Client.Email    = txtEmail.Text.FullTrim();
                Client.Facebook = txtFacebook.Text.FullTrim();
                Client.Viber    = txtViber.Text.FullTrim();
                Client.WhatsApp = txtWhatsApp.Text.FullTrim();
                Client.Other    = txtOther.Text.FullTrim();
                ClientManager.UpdateClient(Client);
            }
            ShowInfoMsg(IsEditMode ? Resources.ClientEditedSeccessfully : Resources.ClientAddedSeccessfully);
            Close();
        }
Example #15
0
        public void AddClientTest()
        {
            // Arrange
            var clientRepositoryMock = Substitute.For <IClientRepository>();

            var sut = new ClientManager(clientRepositoryMock);

            Client client = new Client
            {
                Name        = "Martin Eden",
                PhoneNumber = "555-55-55",
                Balance     = (decimal)6021023
            };

            // Act
            sut.AddClient(client);

            // Asserts
            clientRepositoryMock.Received(1).Insert(Arg.Is <Client>(client));
        }
Example #16
0
        public void GetClientByPeselCheck()
        {
            // arrange
            const int    idClient  = 1;
            const string firstname = "Jan";
            const string surname   = "Kowalski";
            const string telephone = "2132123133";
            const string pesel     = "2142421412421";

            Client client = new Client(idClient, firstname, surname, telephone, pesel);

            ClientManager clientManager = new ClientManager();

            clientManager.AddClient(client);

            // act
            Client obtainedClient = clientManager.GetClient(pesel);

            // assert
            Assert.AreEqual(client, obtainedClient);
        }
Example #17
0
        public void AddClientTest()
        {
            // arrange
            const int    idClient  = 1;
            const string firstname = "Jan";
            const string surname   = "Kowalski";
            const string telephone = "2132123133";
            const string pesel     = "2142421412421";

            Client client = new Client(idClient, firstname, surname, telephone, pesel);

            ClientManager clientManager = new ClientManager();

            // act
            clientManager.AddClient(client);

            // assert
            Client addedClient = clientManager.clients.Last();

            Assert.AreEqual(client, addedClient);
        }
Example #18
0
        public void GetAllTest()
        {
            // arrange
            const int    idClient  = 1;
            const string firstname = "Jan";
            const string surname   = "Kowalski";
            const string telephone = "2132123133";
            const string pesel     = "2142421412421";

            Client client = new Client(idClient, firstname, surname, telephone, pesel);

            ClientManager clientManager = new ClientManager();

            clientManager.AddClient(client);

            List <Client> expectedCollection = clientManager.clients;

            // act
            List <Client> allClients = clientManager.GetAllClients();

            // assert
            CollectionAssert.AreEquivalent(expectedCollection, allClients);
        }
Example #19
0
        private void SaveInvoice()
        {
            ErrorProvider.Clear();
            var    isFormValid = true;
            Client newClient   = null;

            if (txtClientName.Text.IsNullOrEmptyOrWhiteSpace())
            {
                isFormValid = false;
                ErrorProvider.SetError(txtClientName, Resources.ThisFieldIsRequired);
            }
            else if (!ClientsNames.Contains(txtClientName.Text.FullTrim()))
            {
                isFormValid = ShowConfirmationDialog(Resources.ClientNotExists) == DialogResult.Yes;
                newClient   = new Client {
                    Name = txtClientName.Text.FullTrim()
                };
            }
            if (!InvoiceItemVms.Any())
            {
                isFormValid = false;
                ShowErrorMsg(Resources.InvoiceWithoutItems);
            }
            if (!isFormValid)
            {
                return;
            }
            if (!InvoiceItemVms.Any())
            {
                ShowErrorMsg(Resources.NoItemsAdded);
                return;
            }

            if (newClient != null)
            {
                ClientManager.AddClient(newClient);
            }

            var invoice = new Invoice
            {
                ClientId = ClientManager.GetClientIdByName(txtClientName.Text.FullTrim()),
                Date     = dtInvoiceDate.Value,
                Total    = (decimal)dblInTotal.Value,
                Paid     = (decimal)dblInPaid.Value,
                Discount = (decimal)dblInDiscount.Value
            };

            InvoiceManager.AddInvoice(invoice);
            InvoiceItemManager.AddInvoiceItems(InvoiceItemVms.Select(item => new InvoiceItem
            {
                InvoiceId  = invoice.Id,
                MaterialId = item.MaterialId,
                Quantity   = item.Quantity,
                Price      = item.TotalPrice,
                Notes      = item.Notes
            }).ToList());
            if (invoice.Paid > 0)
            {
                InvoicePaymentManager.AddInvoicePayment(new InvoicePayment
                {
                    InvoiceId = invoice.Id,
                    Date      = dtInvoiceDate.Value,
                    Paid      = (decimal)dblInPaid.Value
                });
            }
            MaterialManager.UpdateQuantitiesAfterCreatingInvoice(InvoiceItemVms);
            ShowInfoMsg(Resources.InvoiceCreatedSuccessfully);
            Close();
        }
Example #20
0
        public void Run()
        {
            Log.Write("Starting Server...", LogType.SYSTEM);

            // Setup address for ENet Host
            Address address = new Address();

            address.Port = _configs.PORT;

            // Create ENet Host
            _server = new Host();

            _server.Create(address, _configs.MAX_CLIENTS);

            _status = ServerStatus.RUNNING;

            _StartTime = DateTime.Now;
            Log.Write($"Server Started : {_StartTime.ToShortDateString()} - {_StartTime.ToShortTimeString()}\n\n", LogType.SYSTEM);

            Event netEvent;

            while (_status == ServerStatus.RUNNING)
            {
                // Check Inputs from Console
                CheckServerInput();

                bool polled = false;

                while (!polled)
                {
                    if (_server.CheckEvents(out netEvent) <= 0)
                    {
                        if (_server.Service(15, out netEvent) <= 0)
                        {
                            break;
                        }

                        polled = true;
                    }

                    switch (netEvent.Type)
                    {
                    case EventType.None:
                        break;

                    case EventType.Connect:

                        var errCode = m_ConnectionApprovalManager.ApproveConnection(null, netEvent.Peer.IP);
                        if (errCode == ConnectionApprovalCode.APPROVED)
                        {
                            Log.Write($"Client connected - ID:  {netEvent.Peer.ID}, IP: {netEvent.Peer.IP}", LogType.DEBUG);

                            m_ClientManager.AddClient(netEvent.Peer, 0);
                        }
                        else
                        {
                            // Handle Error
                            Log.Write($"Denied connection: Reason:{m_ConnectionApprovalManager.GetDenyReason(errCode)}, IP: {netEvent.Peer.IP}", LogType.DEBUG);

                            netEvent.Peer.DisconnectNow((uint)errCode);
                        }
                        break;

                    case EventType.Disconnect:
                        Log.Write("Client disconnected - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP, LogType.DEBUG);

                        m_ClientManager.RemoveClient_NetID(netEvent.Peer.ID);
                        break;

                    case EventType.Timeout:
                        Log.Write("Client timeout - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP, LogType.DEBUG);

                        m_ClientManager.RemoveClient_NetID(netEvent.Peer.ID);
                        break;

                    case EventType.Receive:
                        Log.Write("Packet received from - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP + ", Channel ID: " + netEvent.ChannelID + ", Data length: " + netEvent.Packet.Length, LogType.VERBOSE);
                        netEvent.Packet.Dispose();
                        break;
                    }
                }
            }

            Log.Write("Flushing Server...", LogType.SYSTEM);

            _server.Flush();

            Log.Write("Server shut down successfully.", LogType.SYSTEM);
            Log.Write($"Run Time : {Util.Time.GetRunTimeOffset(_StartTime, DateTime.Now)}\n", LogType.SYSTEM);

            Console.ReadKey();
        }
Example #21
0
        static void Main(string[] args)
        {
            ClientManager      clientManager;
            HotelManager       hotelManager;
            ReservationManager reservationManager;

            string control = "s";

            while (control != "0")
            {
                Console.WriteLine("Чтобы создать клиента нажмите 1");
                Console.WriteLine("Чтобы удалить клиента нажмите 2");
                Console.WriteLine("Чтобы создать отель нажмите 3");
                Console.WriteLine("Чтобы удалить отель нажмите 4");
                Console.WriteLine("Чтобы создать бронь нажмите 5");
                Console.WriteLine("Чтобы удалить бронь нажмите 6");
                Console.WriteLine("Чтобы выйти нажмите 0");
                Console.Write("Ввод: ");
                control = Console.ReadLine();
                if (control == "1")
                {
                    clientManager = new ClientManager();
                    Console.Write("Введите имя: ");
                    string name = Console.ReadLine();
                    Console.Write("Введите Фамилию: ");
                    string surname = Console.ReadLine();
                    Console.Write("Введите возраст: ");
                    string age = Console.ReadLine();
                    clientManager.AddClient(name, surname, int.Parse(age));
                    clientManager.CreateClientsLog();
                }

                if (control == "2")
                {
                    clientManager = new ClientManager();
                    Thread.Sleep(300);
                    if (clientManager.clients.Count == 0)
                    {
                        Console.WriteLine("Увы сегодня некого удалить!");
                        Console.WriteLine(" ");
                    }
                    else
                    {
                        int numbClient = 0;
                        foreach (Client client in clientManager.clients)
                        {
                            Console.WriteLine($"{numbClient + 1}. {client.Name}");
                        }
                        Console.Write("Выберите номер кого удалить:");
                        string numbClient2 = Console.ReadLine();
                        numbClient = int.Parse(numbClient2);

                        clientManager.RemoveClient(clientManager.clients[numbClient - 1].IdClient);
                        Console.WriteLine("Он больше не забронирует не один отель :) ");
                        Console.WriteLine(" ");
                    }
                }

                if (control == "3")
                {
                    hotelManager = new HotelManager();
                    try
                    {
                        Console.Write("Введите название: ");
                        string name = Console.ReadLine();
                        Console.Write("Введите рейтинг: ");
                        string rating = Console.ReadLine();
                        Console.Write("Введите страну: ");
                        string country = Console.ReadLine();
                        hotelManager.AddHotel(name, Double.Parse(rating), country);
                        hotelManager.CreateHotelsLog();
                    } catch
                    {
                        Console.WriteLine("Некоректные данные. Повторите попытку");
                    }
                }

                if (control == "4")
                {
                    hotelManager = new HotelManager();
                    Thread.Sleep(300);
                    if (hotelManager.hotels.Count == 0)
                    {
                        Console.WriteLine("Ни одного отеля нет для разрушения");
                        Console.WriteLine(" ");
                    }
                    else
                    {
                        int numbHotel = 0;
                        foreach (Hotel hotel in hotelManager.hotels)
                        {
                            Console.WriteLine($"{numbHotel + 1}. {hotel.Name} - {hotel.Country}");
                        }
                        Console.Write("Введите номер отеля для разрушения: ");
                        string numbHotel2 = Console.ReadLine();
                        numbHotel = int.Parse(numbHotel2);
                        hotelManager.RemoveHotel(hotelManager.hotels[numbHotel - 1].IdHotel);
                        Console.WriteLine("Отель разрушен! Постояльцы переселенны , персонал ищет работу в другом месте :)");
                        Console.WriteLine(" ");
                    }
                }

                if (control == "5")
                {
                    reservationManager = new ReservationManager();
                    Thread.Sleep(300);
                    if (reservationManager.clients.Count == 0 || reservationManager.hotels.Count == 0)
                    {
                        Console.WriteLine("В базе нет клиентов или отелей. Добавьте их!");
                        Console.WriteLine(" ");
                        continue;
                    }
                    Console.WriteLine("Выберите для какого клиента: ");
                    int numbClient = 0;
                    foreach (Client client in reservationManager.clients)
                    {
                        Console.WriteLine($"{numbClient + 1}.{client.Name}");
                    }
                    Console.Write("Введите нормер клиента: ");
                    string numbClient2 = Console.ReadLine();
                    numbClient = int.Parse(numbClient2);
                    reservationManager.AddClient(reservationManager.clients[numbClient - 1].IdClient);
                    Console.WriteLine("Выберите отель: ");
                    int numbHotel = 0;
                    foreach (Hotel hotel in reservationManager.hotels)
                    {
                        Console.WriteLine($"{numbHotel + 1}.{hotel.Name} - {hotel.Country}");
                    }
                    Console.Write("Введите нормер отеля: ");
                    string numbHotel2 = Console.ReadLine();
                    numbHotel = int.Parse(numbHotel2);
                    reservationManager.AddHotel(reservationManager.hotels[numbHotel - 1].IdHotel);

                    try
                    {
                        Console.WriteLine("Введите даты бронирования (от и до) : ");
                        Console.Write("Введите год (дата от):");
                        string d1Year = Console.ReadLine();
                        Console.Write("Введите месяц (дата от):");
                        string d1Month = Console.ReadLine();
                        Console.Write("Введите день (дата от):");
                        string d1Day = Console.ReadLine();

                        DateTime dateIn = new DateTime(int.Parse(d1Year), int.Parse(d1Month), int.Parse(d1Day));

                        Console.Write("Введите год (дата до):");
                        string d2Year = Console.ReadLine();
                        Console.Write("Введите месяц (дата до):");
                        string d2Month = Console.ReadLine();
                        Console.Write("Введите день (дата до):");
                        string d2Day = Console.ReadLine();

                        DateTime dateOut = new DateTime(int.Parse(d2Year), int.Parse(d2Month), int.Parse(d2Day));

                        reservationManager.AddDateReserv(dateIn, dateOut);
                        reservationManager.AddReservation();
                    } catch
                    {
                        Console.WriteLine("Дата некоректно введена попробуйте снова");
                        Console.WriteLine(" ");
                    }
                }

                if (control == "6")
                {
                    reservationManager = new ReservationManager();
                    Thread.Sleep(300);
                    if (reservationManager.reservations.Count == 0)
                    {
                        Console.WriteLine("Ни одной брони нет в списке");
                        Console.WriteLine(" ");
                    }
                    else
                    {
                        int numbReserv = 0;
                        foreach (Reservation reserv in reservationManager.reservations)
                        {
                            Console.WriteLine($"{numbReserv + 1}. {reserv.ClientCurrent.Name} {reserv.HotelCurrent.Name} - {reserv.HotelCurrent.Country}");
                            Console.WriteLine($"с {reserv.CheckInDate} по {reserv.CheckOutDate} ");
                        }

                        Console.Write("Введите номер брони:");
                        string numbReserv2 = Console.ReadLine();
                        numbReserv = int.Parse(numbReserv2);
                        reservationManager.RemoveReservation(reservationManager.reservations[numbReserv - 1].IdReservation);
                        Console.WriteLine("Теперь на эту дату отель забронирует кто то другой :)");
                        Console.WriteLine(" ");
                    }
                }
            }
        }
Example #22
0
        public void AddClient(ClientDTO client)
        {
            ClientManager clientManager = new ClientManager();

            clientManager.AddClient(client);
        }
        public ActionResult ResumeFcl(FormCollection fc)
        {
            try
            {
                var viewModel = new ResumeDossierFcl();
                viewModel.Clients           = rezCli;
                viewModel.DossierFclExports = rezDoss;
                viewModel.Bookings          = rezBkg;
                viewModel.InstruTrans       = rezInstru;
                viewModel.Transporteurs     = rezTrans;
                viewModel.Mads  = rezMad;
                viewModel.Devis = rezDevi;
                viewModel.CompagnieMaritimes = rezCompa;
                viewModel.Conteneurs         = lstTC;
                viewModel.Marchandises       = lsMarchandises;
                viewModel.LigneDeVentes      = lstLV;

                //Instanciation de l'objet client
                rezCli.CLT_ID      = leCliDuDoss.NewIdClient();
                rezCli.CLT_REF     = fc["Clients.CLT_REF"];
                rezCli.CLT_NOMRAIS = fc["Clients.CLT_NOMRAIS"];
                if (!String.IsNullOrEmpty(fc["Clients.CLT_SIRET"]))
                {
                    rezCli.CLT_SIRET = Convert.ToInt32(fc["Clients.CLT_SIRET"]);
                }
                else
                {
                    rezCli.CLT_SIRET = 0;
                }

                rezCli.CLT_ADRESSE = fc["Clients.CLT_ADRESSE"];
                rezCli.CLT_CP      = fc["Clients.CLT_CP"];
                rezCli.CLT_VILLE   = fc["Clients.CLT_VILLE"];
                rezCli.CLT_PAYS    = fc["Clients.CLT_PAYS"];
                leCliDuDoss.AddClient(rezCli);
                //db.SaveChanges();

                //Instanciation de l'objet dossier
                rezDoss.FCL_ID = (DateTime.Now.Year + "E" + leDoss.numDossCompteur().ToString());
                rezDoss.CLT_ID = rezCli.CLT_ID;
                leDoss.AddDossier(rezDoss);

                //Instanciation de l'objet Transporteur
                rezTrans.TRS_REF     = lesTransDuDoss.numTransCompteur().ToString();
                rezTrans.TYTRANS_ID  = Convert.ToInt32(fc["TYTRANS_ID"]);
                rezTrans.TRS_NOMRAIS = fc["Transporteurs.TRS_NOMRAIS"];
                lesTransDuDoss.AddTrans(rezTrans);

                //Instanciation de l'objet MAD
                rezMad.MAD_ID          = madDuDoss.NumMad();
                rezMad.MAD_LIEU_ENLEV  = fc["Mads.MAD_LIEU_ENLEV"];
                rezMad.MAD_ADRES_ENLEV = fc["Mads.MAD_ADRES_ENLEV"];
                if (!String.IsNullOrEmpty(fc["Mads.MAD_DATE"]))
                {
                    rezMad.MAD_DATE = Convert.ToDateTime(fc["Mads.MAD_DATE"]);
                }
                else
                {
                    rezMad.MAD_DATE = DateTime.Now;
                }
                madDuDoss.AddMad(rezMad);


                //Instanciation de l'objet Instruction Transporteur
                rezInstru.INSTR_NUMOFR = instruDoss.NumOffreAuto();
                rezInstru.MAD_ID       = rezMad.MAD_ID;
                rezInstru.FCL_ID       = rezDoss.FCL_ID;
                rezInstru.TRS_REF      = rezTrans.TRS_REF;
                instruDoss.AddInstruTrans(rezInstru);

                //Instanciation de l'objet CompagnieMaritime
                rezCompa.CM_REF     = cmDuDoss.numCompMaritime().ToString();
                rezCompa.CM_NOMRAIS = fc["CompagnieMaritimes.CM_NOMRAIS"];
                rezCompa.CM_SIRET   = 0;
                rezCompa.CM_ADRESSE = "";
                rezCompa.CM_CP      = "";
                rezCompa.CM_VILLE   = fc["CompagnieMaritimes.CM_VILLE"];
                cmDuDoss.AddCM(rezCompa);

                //Instanciation de l'objet Booking
                rezBkg.BKG_ID        = lesBkDuDoss.CompteurNumBkg();
                rezBkg.BKG_NUM       = fc["Bookings.BKG_NUM"];
                rezBkg.FCL_ID        = rezDoss.FCL_ID;
                rezBkg.CM_REF        = rezCompa.CM_REF;
                rezBkg.BKG_NOMNAVIRE = fc["Bookings.BKG_NOMNAVIRE"];
                rezBkg.BKG_DATE      = DateTime.Now;
                if (!String.IsNullOrEmpty(fc["Bookings.BKG_ETA"]))
                {
                    rezBkg.BKG_ETA = Convert.ToDateTime(fc["Bookings.BKG_ETA"]);
                }
                else
                {
                    rezBkg.BKG_ETA = DateTime.Now;
                }
                if (!String.IsNullOrEmpty(fc["Bookings.BKG_ETD"]))
                {
                    rezBkg.BKG_ETD = Convert.ToDateTime(fc["Bookings.BKG_ETD"]);
                }
                else
                {
                    rezBkg.BKG_ETD = DateTime.Now;
                }
                rezBkg.BKG_FORWARDER     = "";
                rezBkg.BKG_LOADTERM      = "";
                rezBkg.BKG_NUMVYG        = "";
                rezBkg.BKG_PORTARRIVEE   = fc["Bookings.BKG_PORTARRIVEE"];
                rezBkg.BKG_PORTDEPART    = fc["Bookings.BKG_PORTDEPART"];
                rezBkg.BKG_PORTFORWARDER = "";
                rezBkg.BKG_REFCOTATION   = "";
                rezBkg.BKG_OBS           = "";
                rezBkg.BKG_REFBL         = fc["Bookings.BKG_REFBL"];
                lesBkDuDoss.AddBooking(rezBkg);


                ViewBag.TYTRANS_ID = new SelectList(db.TypeTransporteurs, "TYTRANS_ID", "TYTRANS_LIBELLE");
                return(RedirectToAction("Index", new { Controller = "DossierFclExports" }));
            }
            catch (RetryLimitExceededException /* dex */)
            {
                ModelState.AddModelError(" ", "Unable to save changes. Try again, and if the problem persists see your system administrator");
            }
            return(RedirectToAction("Details", new { Controller = "DossierFclExports", id = rezDoss.FCL_ID }));
        }
Example #24
0
        //private System.Timers.Timer _userStateCheck = new System.Timers.Timer(10000);

        //private void _userStateCheck_Elapsed(object sender, ElapsedEventArgs e)
        //{
        //    this._userStateCheck.Stop();
        //    try
        //    {
        //        string[] tokens = ClientManager.GetInvalidClients();
        //        if (null != tokens)
        //        {
        //            foreach (var token in tokens)
        //            {
        //                string userName = ClientManager.GetClientUserName(token);
        //                LogHelper.Instance.AddInfoLog("玩家 [" + userName + "] 掉线,退出登录, IP=" + ClientManager.GetClientIP(token));

        //                PlayerController.Instance.LogoutPlayer(userName);
        //                RSAProvider.RemoveRSA(token);
        //                ClientManager.RemoveClient(token);
        //                lock (this._callbackDicLocker)
        //                {
        //                    this._callbackDic.Remove(token);
        //                }
        //            }
        //        }
        //    }
        //    catch
        //    {
        //    }
        //    finally
        //    {
        //        if (App.ServiceToRun.IsStarted)
        //        {
        //            this._userStateCheck.Start();
        //        }
        //    }
        //}

        public OperResultObject Login(string UserLoginName, string password, string key, string mac, string clientVersion)
        {
#if Delay
            Thread.Sleep(5000);
#endif

            OperResultObject resultObj = new OperResultObject();

#if V1
            resultObj.OperResultCode = OperResult.RESULTCODE_FALSE;
            return(resultObj);
#endif

            if (String.IsNullOrEmpty(UserLoginName) || String.IsNullOrEmpty(password))
            {
                resultObj.OperResultCode = OperResult.RESULTCODE_USERNAME_PASSWORD_ERROR;
                return(resultObj);
            }
            if (!string.IsNullOrEmpty(GlobalConfig.CurrentClientVersion) && GlobalConfig.CurrentClientVersion != clientVersion)
            {
                resultObj.OperResultCode = OperResult.RESULTCODE_CLIENT_VERSION_OLD;
                //resultObj.Message = "VERSIONERROR";
                return(resultObj);
            }

            string     token    = null;
            string     ip       = ClientManager.GetCurrentIP();
            string     userName = "";
            PlayerInfo player   = null;
            try
            {
                player = PlayerController.Instance.GetPlayerInfoByUserLoginName(UserLoginName);
                if (player == null)
                {
                    resultObj.OperResultCode = OperResult.RESULTCODE_USERNAME_PASSWORD_ERROR;
                    return(resultObj);
                }
                userName = player.SimpleInfo.UserName;
                token    = ClientManager.GetToken(player.SimpleInfo.UserName);
                if (!string.IsNullOrEmpty(token))
                {
                    new Thread(new ParameterizedThreadStart(o =>
                    {
                        this.KickoutByUser(o.ToString());
                    })).Start(token);

                    //return "ISLOGGED";
                }

                if (password != player.SimpleInfo.Password)
                {
                    resultObj.OperResultCode = OperResult.RESULTCODE_USERNAME_PASSWORD_ERROR;
                    return(resultObj);
                }

                resultObj = PlayerController.Instance.CheckPlayerIsLocked(player.SimpleInfo.UserID, player.SimpleInfo.UserName);
                if (resultObj.OperResultCode != OperResult.RESULTCODE_TRUE)
                {
                    return(resultObj);
                }

                if (player.SimpleInfo.InvitationCode == GlobalData.TestInvitationCode)
                {
                    try
                    {
                        var logState = DBProvider.TestUserLogStateDBProvider.GetTestUserLogStateByMac(mac);
                        if (logState == null)
                        {
                            logState = DBProvider.TestUserLogStateDBProvider.GetTestUserLogStateByUserName(player.SimpleInfo.UserName);
                            if (logState != null)
                            {
                                resultObj.OperResultCode = OperResult.RESULTCODE_USERLOGIN_ISTESTUSER_LOGINLIMIT;
                                return(resultObj);
                            }
                            DBProvider.TestUserLogStateDBProvider.AddTestUserLogState(player.SimpleInfo.UserName, mac, ip);
                        }
                        else
                        {
                            if (logState.UserName != player.SimpleInfo.UserName)
                            {
                                resultObj.OperResultCode = OperResult.RESULTCODE_USERLOGIN_ISTESTUSER_LOGINLIMIT;
                                return(resultObj);
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        LogHelper.Instance.AddErrorLog("Test User [" + userName + "] Add Exception.", exc);
                    }
                }

                player.SimpleInfo.LastLoginIP  = ip;
                player.SimpleInfo.LastLoginMac = mac;
                PlayerController.Instance.LoginPlayer(player);

                RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
                rsa.FromXmlString(key);

                token = Guid.NewGuid().ToString();
                RSAProvider.SetRSA(token, rsa);
                RSAProvider.LoadRSA(token);

                ClientManager.AddClient(player.SimpleInfo.UserName, token);
                lock (this._callbackDicLocker)
                {
                    this._callbackDic[token] = new Queue <CallbackInfo>();
                }

                LogHelper.Instance.AddInfoLog("玩家 [" + userName + "] 登录矿场, IP=" + ip + ", Mac=" + mac);
            }
            catch (Exception ex)
            {
                LogHelper.Instance.AddErrorLog("玩家 [" + userName + "] 登录矿场失败, IP=" + ip + ", Mac=" + mac, ex);
            }
            if (!string.IsNullOrEmpty(token))
            {
                PlayerActionController.Instance.AddLog(userName, MetaData.ActionLog.ActionType.Login, (int)player.FortuneInfo.Exp / 2000);
                new Thread(new ParameterizedThreadStart(o =>
                {
                    this.LogedIn(o.ToString());
                })).Start(token);
            }

            resultObj.OperResultCode = OperResult.RESULTCODE_TRUE;
            resultObj.Message        = token;
            return(resultObj);
        }