Exemplo n.º 1
0
 private void addBranch_Click(object sender, EventArgs e)
 {
     if (BranchName.Text != "")
     {
         try
         {
             Request request = new Request(RequestType.AddBranch, new Branch(0, BranchName.Text));
             byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
             socket.Send(buffer);
             buffer = new byte[1024];
             int size = socket.Receive(buffer);
             Array.Resize(ref buffer, size);
             bool answer = (bool)SerializeDeserializeObject.Deserialize(buffer);
             if (answer)
             {
                 new MessageBx("L'ajout a réussi", "L'ajout").Show();
                 BranchName.Text = "";
                 actualiserLeTableau();
             }
             else
             {
                 new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
             }
         }
         catch (Exception)
         {
             new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").ShowDialog();
         }
     }
     else
     {
         new MessageBx("Veuillez remplir le champ", "Attention").ShowDialog();
     }
 }
Exemplo n.º 2
0
        public SetupAppObj SetupApplication(string prevToolVersion, string newToolVersion, bool throwException)
        {
            SetupAppObj returnObj = new SetupAppObj();
            Service     myService = null;

            try
            {
                myService = new Service();
                GetValidWebServiceUrl(true);
                myService.Url             = _currentWebServiceUrl.Url;
                myService.AuthHeaderValue = _soapHeader;
                string retValue = myService.SetupApplication((Guid)_soapHeader.ToolId, (Guid)_soapHeader.ApplicationKey, prevToolVersion, newToolVersion);
                returnObj = SerializeDeserializeObject.DeserializeObject <SetupAppObj>(retValue);
            }
            catch (Exception ex)
            {
                if (throwException)
                {
                    throw ex;
                }
            }
            finally
            {
                if (myService != null)
                {
                    myService.Dispose();
                }
                myService = null;
            }
            return(returnObj);
        }
Exemplo n.º 3
0
        public allStudentsReportViewerForm(Socket socket)
        {
            this.socket = socket;

            branches = new List <AllStudentsReportAdapter>();
            Request request = new Request(RequestType.GetStudentByBranch, null);

            byte[] buffer = SerializeDeserializeObject.Serialize(request);
            socket.Send(buffer);
            buffer = new byte[1024 * 1024];
            int size = socket.Receive(buffer);

            Array.Resize(ref buffer, size);
            Dictionary <string, List <Student> > StudentsByBranch = (Dictionary <string, List <Student> >)SerializeDeserializeObject.Deserialize(buffer);


            students = new Dictionary <string, List <OneStudentReportAdapter> >();
            foreach (var item in StudentsByBranch)
            {
                List <OneStudentReportAdapter> studentAdapters = new List <OneStudentReportAdapter>();
                foreach (var student in item.Value)
                {
                    studentAdapters.Add(new OneStudentReportAdapter(student));
                }
                students.Add(item.Key, studentAdapters);
            }


            foreach (var item in students.Keys)
            {
                branches.Add(new AllStudentsReportAdapter(item, null));
            }
            InitializeComponent();
        }
Exemplo n.º 4
0
        public Graphic(Socket sock)
        {
            InitializeComponent();
            socket = sock;
            Request request = new Request(RequestType.GetStatics, null);

            byte[] buffer = SerializeDeserializeObject.Serialize(request);
            socket.Send(buffer);
            buffer = new byte[1024 * 1024];
            int size = socket.Receive(buffer);

            Array.Resize(ref buffer, size);
            int total = 0;
            Dictionary <string, int> answer = (Dictionary <string, int>)SerializeDeserializeObject.Deserialize(buffer);

            foreach (var item in answer)
            {
                total += item.Value;
            }
            int position = 0;

            foreach (var item in answer)
            {
                string percentage = Math.Round(((double)(item.Value * 100) / total), 2) + "%";
                setGraph(item.Value, item.Key, percentage, position);
                position += 1;
                //Console.WriteLine(percentage + "  " + position);
            }
        }
Exemplo n.º 5
0
        private void validate_Click(object sender, EventArgs e)
        {
            if (currrentPass.Text == "" || newPassword.Text == "")
            {
                new MessageBx("Veuillez remplir tous les champs", "Attention").Show();
            }
            else
            {
                Request request = new Request(RequestType.UpdateUser, new User(idUser, username.Text, newPassword.Text));
                byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                socket.Send(buffer);
                buffer = new byte[1024];
                int size = socket.Receive(buffer);
                Array.Resize(ref buffer, size);
                bool answer = (bool)SerializeDeserializeObject.Deserialize(buffer);
                Console.WriteLine(idUser + "");
                Console.WriteLine(answer);
                if (answer)
                {
                    new MessageBx("La modification a réussi", "Modification").Show();
                    user.Text = username.Text;
                }
                else
                {
                    new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                }

                param.Visible = false;
            }
        }
Exemplo n.º 6
0
        private void addStudent_Click(object sender, EventArgs e)
        {
            string sex = female.Text;

            if (male.Checked)
            {
                sex = male.Text;
            }
            if (!checkEmptyAttributes())
            {
                Request request = new Request(RequestType.AddStudent, new Student(0, (Branch)branchStudent.SelectedItem, cneStudent.Text, studentName.Text, studenLastName.Text, sex, address.Text, dateTimePicker1.Value, phone.Text));
                byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                socket.Send(buffer);
                buffer = new byte[1024];
                int size = socket.Receive(buffer);
                Array.Resize(ref buffer, size);
                bool answer = (bool)SerializeDeserializeObject.Deserialize(buffer);
                if (answer)
                {
                    new MessageBx("L'ajout a réussi", "L'ajout").Show();
                }
                else
                {
                    new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                }
                resetAllAttributes();
                refreshDataGrid();
            }
            else
            {
                new MessageBx("Veuillez remplir tous les champs", "Attention").Show();
            }
        }
Exemplo n.º 7
0
        public List <GF.BrowserGame.Schema.Serializable.Community> GetUserCommunityList(Guid toolId, bool throwException)
        {
            List <GF.BrowserGame.Schema.Serializable.Community> communityList = new List <GF.BrowserGame.Schema.Serializable.Community>();
            Service myService = null;

            try
            {
                myService = new Service();
                GetValidWebServiceUrl(true);
                myService.Url             = _currentWebServiceUrl.Url;
                myService.AuthHeaderValue = _soapHeader;
                string retValue = myService.GetUserCommunityData(toolId);
                communityList = SerializeDeserializeObject.DeserializeObject <List <GF.BrowserGame.Schema.Serializable.Community> >(retValue);
            }
            catch (Exception ex)
            {
                if (throwException)
                {
                    throw ex;
                }
            }
            finally
            {
                if (myService != null)
                {
                    myService.Dispose();
                }
                myService = null;
            }
            return(communityList);
        }
Exemplo n.º 8
0
 internal static string SerializeObjectToString <T>(T obj, string password)
 {
     try
     {
         //return Encryption.EncryptString(SerializeDeserializeObject.SerializeObject<T>(obj), password);
         return(SerializeDeserializeObject.SerializeObject <T>(obj));
     }
     catch (Exception ex)
     {
         return(Constants.ERROR);
     }
 }
Exemplo n.º 9
0
 internal static T DeSerializeObjectFromString <T>(string encryptedString, string password)
 {
     try
     {
         //return SerializeDeserializeObject.DeserializeObject<T>(Encryption.DecryptString(encryptedString, password));
         return(SerializeDeserializeObject.DeserializeObject <T>(encryptedString));
     }
     catch (Exception ex)
     {
         return(default(T));
     }
 }
Exemplo n.º 10
0
 internal static T DeSerializeFromFile <T>(string fileName, string password)
 {
     try
     {
         //string encryptedData = SerializeDeserializeObject.DeserializeObjectFromFile<String>(fileName);
         //return SerializeDeserializeObject.DeserializeObject<T>(Encryption.DecryptString(encryptedData, password));
         return(SerializeDeserializeObject.DeserializeObjectFromFile <T>(fileName));
     }
     catch (Exception ex)
     {
         return(default(T));
     }
 }
Exemplo n.º 11
0
 internal static bool SerializeToFile <T>(T obj, string fileName, string password)
 {
     try
     {
         //string encryptedData = Encryption.EncryptString(SerializeDeserializeObject.SerializeObject<T>(obj), password);
         //SerializeDeserializeObject.SerializeObjectToFile<String>(fileName, true, encryptedData);
         SerializeDeserializeObject.SerializeObjectToFile <T>(fileName, true, obj);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemplo n.º 12
0
        internal WebServiceSettings GetLatestWebServiceSettings(bool throwException)
        {
            WebServiceSettings webServiceSettings    = null;
            WebBrowserClient   webClient             = new WebBrowserClient();
            string             webServiceSettingsUrl = GetCurrenWebServiceSettingsUrl();

            int retries = 1;

TryAgain:
            try
            {
                string webServiceSettingsString = webClient.GetPage(new Uri(webServiceSettingsUrl), "", true);

                if (!string.IsNullOrEmpty(webServiceSettingsString))
                {
                    try
                    {
                        webServiceSettingsString = SerializeDeserializeObject.DeserializeObject <String>(webServiceSettingsString);
                        webServiceSettingsString = Encryption.DecryptString(webServiceSettingsString);
                        webServiceSettings       = SerializeDeserializeObject.DeserializeObject <WebServiceSettings>(webServiceSettingsString);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(Constants.Message.TRY_NEXT_URL);
                    }
                }
                else
                {
                    throw new Exception(Constants.Message.TRY_NEXT_URL);
                }
            }
            catch
            {
                if (retries < GetNumberOfWebServiceSettingsUrl())
                {
                    retries++;
                    webServiceSettingsUrl = GetNextWebServiceSettingsUrl();
                    goto TryAgain;
                }
                else if (throwException)
                {
                    throw new Exception(Constants.Message.WEBSERVICE_SETTINGS_NOT_FOUND);
                }
            }

            return(webServiceSettings);
        }
Exemplo n.º 13
0
        private void updateBranch_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                //int lignes = 0;
                for (int i = 0; i < selectedRowCount; i++)
                {
                    int    id = Int32.Parse(dataGridView1.SelectedRows[i].Cells["Id_Filière"].Value.ToString());
                    string branchNameTable = dataGridView1.SelectedRows[i].Cells["Nom_Filière"].Value.ToString();
                    try
                    {
                        MessageUpdate msg = new MessageUpdate();
                        msg.UpdateNamebranch.Text = branchNameTable;
                        msg.ShowDialog();
                        Request request = new Request(RequestType.UpdateBranch, new Branch(id, msg.UpdateNamebranch.Text));
                        byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                        socket.Send(buffer);
                        buffer = new byte[1024];
                        int size = socket.Receive(buffer);
                        Array.Resize(ref buffer, size);
                        bool answer = (bool)SerializeDeserializeObject.Deserialize(buffer);
                        if (answer)
                        {
                            new MessageBx("La modification a réussi", "Modification").ShowDialog();
                            actualiserLeTableau();
                        }
                        else
                        {
                            new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").ShowDialog();
                        }
                    }
                    catch (Exception)
                    {
                        new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").ShowDialog();
                    }
                }
            }
            else
            {
                new MessageBx("Veuillez sélectionner une ligne", "Attention").ShowDialog();
            }
        }
Exemplo n.º 14
0
        private void deleteStudent_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                for (int i = 0; i < selectedRowCount; i++)
                {
                    // get the data
                    try
                    {
                        string  cne     = dataGridView1.SelectedRows[i].Cells["CNE"].Value.ToString();
                        Request request = new Request(RequestType.DeleteStudent, cne);
                        byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                        socket.Send(buffer);
                        buffer = new byte[1024];
                        int size = socket.Receive(buffer);
                        Array.Resize(ref buffer, size);
                        bool answer = (bool)SerializeDeserializeObject.Deserialize(buffer);
                        if (answer)
                        {
                            new MessageBx("La suppression a réussi", "Suppression").Show();
                            refreshDataGrid();
                        }
                        else
                        {
                            new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                        }
                    }
                    catch (Exception)
                    {
                        new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                    }
                }
            }
            else
            {
                new MessageBx("Veuillez sélectionner une ligne", "Attention").Show();
            }
        }
Exemplo n.º 15
0
 private void refreshDataGrid()
 {
     try
     {
         Request request = new Request(RequestType.GetAllStudnets, null);
         byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
         socket.Send(buffer);
         buffer = new byte[1024 * 1024];
         int size = socket.Receive(buffer);
         Array.Resize(ref buffer, size);
         dataGridView1.Rows.Clear();
         List <Student> students = (List <Student>)SerializeDeserializeObject.Deserialize(buffer);
         foreach (var student in students)
         {
             dataGridView1.Rows.Add(student.CNE, student.Nom, student.Prenom, student.Sex, student.DateNessance, student.Adresse, student.Telephone, student.Branch.Nom, student.Id);
         }
     }
     catch (SocketException)
     {
         new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
     }
 }
Exemplo n.º 16
0
 private void getAllBranches()
 {
     try
     {
         Request request = new Request(RequestType.GetAllBranches, null);
         byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
         socket.Send(buffer);
         buffer = new byte[1024];
         int size = socket.Receive(buffer);
         Array.Resize(ref buffer, size);
         dataGridView1.Rows.Clear();
         List <Branch> branches = (List <Branch>)SerializeDeserializeObject.Deserialize(buffer);
         foreach (Branch branch in branches)
         {
             branchStudent.Items.Add(branch);
         }
     }
     catch (SocketException ex)
     {
         new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show(); Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 17
0
        private void getStudentByCNE(object sender, EventArgs e)
        {
            if (cneSearch.Text != "")
            {
                try
                {
                    Request request = new Request(RequestType.GetOneStudnet, cneSearch.Text);
                    byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                    socket.Send(buffer);
                    buffer = new byte[1024 * 1024];
                    int size = socket.Receive(buffer);
                    Array.Resize(ref buffer, size);
                    Dictionary <bool, Student> answer = SerializeDeserializeObject.Deserialize(buffer) as Dictionary <bool, Student>;

                    foreach (var item in answer)
                    {
                        if (item.Key)
                        {
                            dataGridView1.Rows.Clear();
                            dataGridView1.Rows.Add(item.Value.CNE, item.Value.Nom, item.Value.Prenom, item.Value.Sex, item.Value.DateNessance, item.Value.Adresse, item.Value.Telephone, item.Value.Branch.Nom, item.Value.Id);
                            cneSearch.Text = "";
                        }
                        else
                        {
                            new MessageBx("Veuillez vérifier le CNE", "Attention").Show();
                        }
                    }
                }
                catch (SocketException)
                {
                    new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                }
            }
            else
            {
                new MessageBx("Veuillez remplir le champ", "Attention").Show();
            }
        }
Exemplo n.º 18
0
        private void iconButton2_Click(object sender, EventArgs e)
        {
            if (cneStudent.Text != "")
            {
                try
                {
                    //get the student by his cne from the server.
                    Request request = new Request(RequestType.GetOneStudnet, cneStudent.Text);
                    byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                    socket.Send(buffer);
                    buffer = new byte[2048];
                    int size = socket.Receive(buffer);
                    Array.Resize(ref buffer, size);
                    Dictionary <bool, Student> answer = SerializeDeserializeObject.Deserialize(buffer) as Dictionary <bool, Student>;

                    /*                    FolderBrowserDialog folder = new FolderBrowserDialog();
                     *                  if (folder.ShowDialog() == DialogResult.OK)
                     *                  {*/
                    if (answer.Keys.First())
                    {
                        new oneStudentReportViewerForm(answer.Values.First()).Show();
                        cneStudent.Text = "";
                    }
                    else
                    {
                        new MessageBx("Veuillez vérifier le CNE", "Attention").Show();
                    }
                }
                catch (SocketException)
                {
                    new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                }
            }
            else
            {
                new MessageBx("Veuillez remplir le champs", "Attention").Show();
            }
        }
Exemplo n.º 19
0
        private void signIn_Click(object sender, EventArgs e)
        {
            User user;

            try
            {
                string serverIp = ConfigurationManager.AppSettings["serverIpAddress"];
                int    port     = Int32.Parse(ConfigurationManager.AppSettings["communicationPort"]);
                socket        = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                localEndPoint = new IPEndPoint(IPAddress.Parse(serverIp), port);
                socket.Connect(localEndPoint);
                user = new User(0, username.Text, password.Text);
                Request request = new Request(RequestType.CheckUser, user);
                byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                socket.Send(buffer);
                buffer = new byte[2048];
                int size = socket.Receive(buffer);
                Array.Resize(ref buffer, size);
                Dictionary <bool, int> answer = (Dictionary <bool, int>)SerializeDeserializeObject.Deserialize(buffer);

                if (answer.Keys.First())
                {
                    new MainForm(answer.Values.First(), username.Text, socket, this).Show();
                    Hide();
                }
                else
                {
                    new MessageBx("Le mot de passe ou le nom d'utilisateur\nest incorrect", "Attention").ShowDialog();
                }
            }
            catch (SocketException)
            {
                socket.Close();
                new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").ShowDialog();
            }
        }
Exemplo n.º 20
0
 private void actualiserLeTableau()
 {
     try
     {
         //Création de l'objet request à comme paramètre la demande de type avoir toutes les filières.
         Request request = new Request(RequestType.GetAllBranches, null);
         // la sérialisation de l'objet requeqt.
         byte[] buffer = SerializeDeserializeObject.Serialize(request);
         socket.Send(buffer);                                                                    // Envoyer l'objet.
         buffer = new byte[1024];                                                                // réinitialiser le buffer.
         int size = socket.Receive(buffer);                                                      // Recevoir la réponse du serveur.
         Array.Resize(ref buffer, size);                                                         // redimensionner le buffer
         List <Branch> filieres = (List <Branch>)SerializeDeserializeObject.Deserialize(buffer); // la sérialisation de la réponse.
         dataGridView1.Rows.Clear();
         foreach (Branch filiere in filieres)
         {
             dataGridView1.Rows.Add(filiere.Id, filiere.Nom);
         }
     }
     catch (SocketException)
     {
         new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").ShowDialog();
     }
 }
Exemplo n.º 21
0
        public List <Student> ReadFromExcel(String filePath)
        {
            errorMessages = new List <string>();
            List <Student> students = new List <Student>();

            //getting all existed branches as a Dictionary of <name, id>
            Dictionary <string, int> branches = new Dictionary <string, int>();
            Request request = new Request(RequestType.GetAllBranches, null);

            byte[] buffer = SerializeDeserializeObject.Serialize(request);
            socket.Send(buffer);
            buffer = new byte[1024];
            int size = socket.Receive(buffer);

            Array.Resize(ref buffer, size);

            foreach (var item in (List <Branch>)SerializeDeserializeObject.Deserialize(buffer))
            {
                branches.Add(item.Nom, item.Id);
            }

            string con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";"
                         + @"Extended Properties='Excel 8.0;HDR=Yes;'";

            using (OleDbConnection connection = new OleDbConnection(con))
            {
                try
                {
                    connection.Open();
                    OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection);
                    using (OleDbDataReader dr = command.ExecuteReader())
                    {
                        var columns = new {
                            CNE               = dr.GetOrdinal("CNE"),
                            nom               = dr.GetOrdinal("Nom"),
                            prenom            = dr.GetOrdinal("Prenom"),
                            sex               = dr.GetOrdinal("Sex"),
                            address           = dr.GetOrdinal("Address"),
                            date_de_naissance = dr.GetOrdinal("date de naissance"),
                            telephone         = dr.GetOrdinal("Telephone"),
                            nom_filiere       = dr.GetOrdinal("Filiere")
                        };

                        //checking if the branch existed



                        while (dr.Read())
                        {
                            string branchName = dr.GetString(columns.nom_filiere);
                            if (branches.ContainsKey(branchName))
                            {
                                students.Add(new Student(0, new Branch(branches[branchName], branchName), dr.GetString(columns.CNE), dr.GetString(columns.nom), dr.GetString(columns.prenom), dr.GetString(columns.sex), dr.GetString(columns.address), dr.GetDateTime(columns.date_de_naissance), dr.GetDouble(columns.telephone).ToString()));
                            }
                            else
                            {
                                errorMessages.Add("Impossible d'ajouter l'etudiant " + dr.GetString(columns.nom) + " " + dr.GetString(columns.prenom) //message
                                                  + "\nCause: filiere " + dr.GetString(columns.nom_filiere) + " n'existe pas");
                            }
                        }
                    }
                }
                catch (SocketException ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                    connection.Close();
                    throw ex;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    connection.Close();
                    throw e;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(students);
        }
Exemplo n.º 22
0
        void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            bool knownException = false;

            _celestosUserName = CelestosLogintextBox.Text.Trim();
            _celestosPassword = CelestosPasswordtextBox.Text;
            OgameServiceV1Call webServiceCall = new OgameServiceV1Call(_toolId, "", _applicationId, _celestosUserName, _celestosPassword, null);

            try
            {
                SetupAppObj returnObj = webServiceCall.SetupApplication(_prevToolVersion, _newToolVersion, true);

                if (!returnObj.Error)
                {
                    // _celestosUserId = returnObj.UserId;

                    if (returnObj.IsToolValid && returnObj.IsUserAllowedToUseThisTool)
                    {
                        if (!string.IsNullOrEmpty(returnObj.CommunityData))
                        {
                            try
                            {
                                _userCommunityList = SerializeDeserializeObject.DeserializeObject <List <GF.BrowserGame.Schema.Serializable.Community> >(returnObj.CommunityData);
                            }
                            catch { }

                            if (_userCommunityList != null && _userCommunityList.Count > 0)
                            {
                                e.Result = "Valid credentials";
                                return;
                            }
                        }
                        knownException = true;
                        throw new Exception("Your credentials are valid but unfortunately you have not been allocated to any universes!\r\n\r\nContact your game administrator for more information.");
                    }
                    else if (!returnObj.IsToolValid)
                    {
                        knownException = true;
                        throw new Exception("Your credentials are valid but unfortunately this tool is not currently active or your version is expired!\r\n\r\nDownload a new version or contact an administrator for more information.");
                    }
                    else if (!returnObj.IsUserAllowedToUseThisTool)
                    {
                        knownException = true;
                        throw new Exception("Your credentials are valid but unfortunately you are not allowed to use this tool!\r\n\r\nContact an administrator for more information.");
                    }
                }
                else
                {
                    knownException = true;
                    throw new Exception("Your credentials are valid but unfortunately something went wrong while downloading your account details!\r\n\r\nContact an administrator for more information.");
                }
            }
            catch (SoapException soapEx)
            {
                if (soapEx.Message.Contains("account is not approved"))
                {
                    e.Result = "Authentication has failed because your account is not approved.\r\n\r\nContact an administrator for more information";
                }
                else if (soapEx.Message.Contains("account is locked"))
                {
                    e.Result = "Authentication has failed because your account is locked.\r\n\r\nContact an administrator for more information";
                }
                else if (soapEx.Message.Contains("database problem"))
                {
                    throw new Exception("Network");
                }
                else
                {
                    e.Result = "Wrong credentials";
                }
            }
            catch (Exception ex)
            {
                if (!knownException || ex.Message.Equals("all webservices are down"))
                {
                    throw new Exception("Network");
                }
                else
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 23
0
        private void iconButton5_Click(object sender, EventArgs e)
        {
            Dictionary <string, int> branches = new Dictionary <string, int>();

            foreach (Branch item in branchStudent.Items)
            {
                branches.Add(item.Nom, item.Id);
            }
            var filePath = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "Excel files (*.xls)|*.xls";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;
                }
            }

            //if the user selected a file
            if (!filePath.Equals(""))
            {
                List <Student> students = null;
                try
                {
                    ExcelReader excelReader = new ExcelReader(socket);
                    students = excelReader.ReadFromExcel(filePath);
                    ExcelViewer excelViewer = new ExcelViewer(students);
                    excelViewer.ShowDialog();
                    //if the user confirmed his uploading
                    if (excelViewer.answer)
                    {
                        foreach (var student in students)
                        {
                            Request request = new Request(RequestType.AddStudent, student);
                            byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                            socket.Send(buffer);
                            buffer = new byte[1024];
                            int size = socket.Receive(buffer);
                            Array.Resize(ref buffer, size);
                            bool answer = (bool)SerializeDeserializeObject.Deserialize(buffer);
                            if (!answer)
                            {
                                MessageBx warning = new MessageBx("Probléme", "Probléme");
                                warning.ShowDialog();
                            }
                            else
                            {
                                Console.WriteLine("Student " + student.Nom + " " + student.Prenom + " addedsuccesfully");
                            }
                        }
                        if (ExcelReader.errorMessages.Count > 0)
                        {
                            foreach (var msg in ExcelReader.errorMessages)
                            {
                                MessageBx warning = new MessageBx(msg, "Probléme");
                                warning.ShowDialog();
                            }
                        }
                    }

                    refreshDataGrid();
                }
                catch (SocketException)
                {
                    new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                }
                catch (Exception)
                {
                    new MessageBx("Nous avons rencontré un problème dans la lecture du fichier!\nVeulliez correcter votre fichier et réessayer plus tard.", "Problème du fichier Excel").Show();
                }
            }
        }
Exemplo n.º 24
0
        private void iconButton2_Click(object sender, EventArgs e)
        {
            MessageBoxYesNo messageBoxYesNo = new MessageBoxYesNo("Vous voulez Télécharger le Reporting ?", "Télécharger le Reporting");

            messageBoxYesNo.ShowDialog();
            if (messageBoxYesNo.Answer)
            {
                try
                {
                    Request request = new Request(RequestType.GetStudentByBranch, null);
                    byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                    socket.Send(buffer);
                    buffer = new byte[1024 * 1024];
                    int size = socket.Receive(buffer);
                    Array.Resize(ref buffer, size);
                    Dictionary <string, List <Student> > StudentsByBranch = (Dictionary <string, List <Student> >)SerializeDeserializeObject.Deserialize(buffer);

                    //select the path of the folder where we will store the pdf file
                    FolderBrowserDialog folder = new FolderBrowserDialog();
                    if (folder.ShowDialog() == DialogResult.OK)
                    {
                        // Create the pdf
                        Document document = new Document();
                        PdfWriter.GetInstance(document, new FileStream(folder.SelectedPath + "\\Reporting.pdf", FileMode.Create));
                        document.Open();
                        // ENSAS Logo
                        iTextSharp.text.Image ensasLogo = iTextSharp.text.Image.GetInstance(@".\Resources\logo.png");
                        ensasLogo.ScalePercent(50);
                        ensasLogo.SetAbsolutePosition(document.PageSize.Width - 120f, document.PageSize.Height - 100f);
                        document.Add(ensasLogo);
                        // UCA Logo
                        iTextSharp.text.Image ucaLogo = iTextSharp.text.Image.GetInstance(@".\Resources\ucaLogo.jpg");
                        ucaLogo.ScalePercent(50);
                        ucaLogo.SetAbsolutePosition(15f, document.PageSize.Height - 100f);
                        document.Add(ucaLogo);

                        // Title
                        Paragraph paragraph = new Paragraph(new Phrase("Ecole Nationale des Sciences Appliquées de", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 13f, iTextSharp.text.Font.BOLDITALIC, iTextSharp.text.BaseColor.BLUE)));
                        paragraph.IndentationLeft = 95f;
                        document.Add(paragraph);
                        Paragraph paragraph_2 = new Paragraph(new Phrase("SAFI", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 13f, iTextSharp.text.Font.BOLDITALIC, iTextSharp.text.BaseColor.BLUE)));
                        paragraph_2.IndentationLeft = 250f;
                        document.Add(paragraph_2);

                        //New Lines
                        document.Add(new Paragraph("\n\n\n\n\n"));
                        // Set the data of all students by branch:
                        foreach (var item in StudentsByBranch)
                        {
                            // Create a table
                            PdfPTable table = new PdfPTable(5);
                            table.TotalWidth  = 545f;
                            table.LockedWidth = true;
                            float[] widths = new float[] { 90f, 115f, 140f, 110f, 90f };
                            table.SetWidths(widths);
                            PdfPCell cell = new PdfPCell(new Phrase(item.Key, new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.WHITE)));
                            cell.BackgroundColor = new iTextSharp.text.BaseColor(43, 78, 132);

                            // Added some padding into the headercell
                            cell.PaddingTop          = 10;
                            cell.PaddingBottom       = 10;
                            cell.Colspan             = 5;
                            cell.HorizontalAlignment = 1;
                            table.AddCell(cell);

                            // First Row :
                            PdfPCell cell1 = new PdfPCell(new Phrase("CNE", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLUE)));
                            MakePaddingAndColor(cell1);
                            table.AddCell(cell1);
                            PdfPCell cell2 = new PdfPCell(new Phrase("Nom et prénom", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLUE)));
                            MakePaddingAndColor(cell2);
                            table.AddCell(cell2);
                            PdfPCell cell3 = new PdfPCell(new Phrase("Date de naissance", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLUE)));
                            MakePaddingAndColor(cell3);
                            table.AddCell(cell3);
                            PdfPCell cell4 = new PdfPCell(new Phrase("Adresse", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLUE)));
                            MakePaddingAndColor(cell4);
                            table.AddCell(cell4);
                            PdfPCell cell5 = new PdfPCell(new Phrase("Téléphone", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLUE)));
                            MakePaddingAndColor(cell5);
                            table.AddCell(cell5);


                            // the rest of each table:
                            foreach (var student in item.Value)
                            {
                                table.AddCell(MakePadding(new PdfPCell(new Phrase(student.CNE))));
                                table.AddCell(MakePadding(new PdfPCell(new Phrase(student.Nom.ToUpper() + " " + student.Prenom))));
                                table.AddCell(MakePadding(new PdfPCell(new Phrase(student.DateNessance.ToShortDateString()))));
                                table.AddCell(MakePadding(new PdfPCell(new Phrase(student.Adresse))));
                                table.AddCell(MakePadding(new PdfPCell(new Phrase(student.Telephone))));
                            }

                            // add the table
                            document.Add(table);
                            document.Add(new Paragraph("\n\n"));
                        }

                        document.Close();
                        new MessageBx("Le téléchargement est terminé", "Le téléchargement").Show();
                    }
                }
                catch (SocketException)
                {
                    new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                }
            }
        }
Exemplo n.º 25
0
        private void download_Click(object sender, EventArgs e)
        {
            if (cneStudent.Text != "")
            {
                try
                {
                    //get the student by his cne from the server.
                    Request request = new Request(RequestType.GetOneStudnet, cneStudent.Text);
                    byte[]  buffer  = SerializeDeserializeObject.Serialize(request);
                    socket.Send(buffer);
                    buffer = new byte[2048];
                    int size = socket.Receive(buffer);
                    Array.Resize(ref buffer, size);
                    Dictionary <bool, Student> answer = SerializeDeserializeObject.Deserialize(buffer) as Dictionary <bool, Student>;

                    /*                    FolderBrowserDialog folder = new FolderBrowserDialog();
                     *                  if (folder.ShowDialog() == DialogResult.OK)
                     *                  {*/
                    if (answer.Keys.First())
                    {
                        // Get the folder path
                        string path = string.Empty;
                        FolderBrowserDialog folder = new FolderBrowserDialog();
                        if (folder.ShowDialog() == DialogResult.OK)
                        {
                            path = folder.SelectedPath;

                            Document document = new Document();
                            PdfWriter.GetInstance(document, new FileStream(path + "\\" + answer.Values.First().CNE + ".pdf", FileMode.Create));
                            document.Open();
                            // ENSAS Logo
                            iTextSharp.text.Image ensasLogo = iTextSharp.text.Image.GetInstance(@".\Resources\logo.png");
                            ensasLogo.ScalePercent(50);
                            ensasLogo.SetAbsolutePosition(document.PageSize.Width - 120f, document.PageSize.Height - 100f);
                            document.Add(ensasLogo);
                            // UCA Logo
                            iTextSharp.text.Image ucaLogo = iTextSharp.text.Image.GetInstance(@".\Resources\ucaLogo.jpg");
                            ucaLogo.ScalePercent(50);
                            ucaLogo.SetAbsolutePosition(15f, document.PageSize.Height - 100f);
                            document.Add(ucaLogo);
                            // Title
                            Paragraph paragraph = new Paragraph(new Phrase("Ecole Nationale des Sciences Appliquées de", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 13f, iTextSharp.text.Font.BOLDITALIC, iTextSharp.text.BaseColor.BLUE)));
                            paragraph.IndentationLeft = 95f;
                            document.Add(paragraph);
                            Paragraph paragraph_2 = new Paragraph(new Phrase("SAFI", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 13f, iTextSharp.text.Font.BOLDITALIC, iTextSharp.text.BaseColor.BLUE)));
                            paragraph_2.IndentationLeft = 250f;
                            document.Add(paragraph_2);
                            //New Lines
                            document.Add(new Paragraph("\n\n\n\n\n\n\n\n"));

                            // added name of the student
                            Paragraph title = new Paragraph(new Phrase("Information de L'Etudiant(e): " + answer.Values.First().Nom + " " + answer.Values.First().Prenom, new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14f, iTextSharp.text.Font.BOLDITALIC, iTextSharp.text.BaseColor.BLACK)));
                            title.IndentationLeft = 80f;
                            document.Add(title);

                            //New Lines
                            document.Add(new Paragraph("\n\n\n\n\n"));

                            //  set cne of the setudent
                            Phrase cne = new Phrase("CNE:          ", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK));
                            document.Add(cne);
                            document.Add(new Phrase(answer.Values.First().CNE + "\n\n", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 13f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLUE)));
                            //  set branch name of the setudent
                            Phrase branch = new Phrase("Nom filière:  ", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK));
                            document.Add(branch);
                            document.Add(new Phrase(answer.Values.First().Branch.ToString() + "\n\n\n\n\n\n", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 13f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLUE)));

                            // set the other information:
                            PdfPTable table = new PdfPTable(4);
                            table.TotalWidth  = 520f;
                            table.LockedWidth = true;
                            float[] widths = new float[] { 150f, 150f, 110f, 110f };
                            table.SetWidths(widths);

                            // First  row in the table
                            // First Row :
                            PdfPCell cell1 = new PdfPCell(new Phrase("Date de Naissance", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.WHITE)));
                            MakePaddingAndColor(cell1);
                            table.AddCell(cell1);
                            PdfPCell cell2 = new PdfPCell(new Phrase("Adresse", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.WHITE)));
                            MakePaddingAndColor(cell2);
                            table.AddCell(cell2);
                            PdfPCell cell3 = new PdfPCell(new Phrase("Téléphone", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.WHITE)));
                            MakePaddingAndColor(cell3);
                            table.AddCell(cell3);
                            PdfPCell cell4 = new PdfPCell(new Phrase("Sexe", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.WHITE)));
                            MakePaddingAndColor(cell4);
                            table.AddCell(cell4);


                            // Second  row in the table

                            table.AddCell(MakePadding(new PdfPCell(new Phrase(answer.Values.First().DateNessance.ToShortDateString()))));
                            table.AddCell(MakePadding(new PdfPCell(new Phrase(answer.Values.First().Adresse))));
                            table.AddCell(MakePadding(new PdfPCell(new Phrase(answer.Values.First().Telephone))));
                            table.AddCell(MakePadding(new PdfPCell(new Phrase(answer.Values.First().Sex))));
                            document.Add(table);

                            document.Add(new Paragraph("\n\n\n\n\n\n\n\n\n\n"));
                            document.Add(new Paragraph("Date du jour: " + DateTime.Today.ToShortDateString() +
                                                       "                                                                                 " + "Signature"));
                            document.Close();

                            new MessageBx("Le téléchargement est terminé", "Le téléchargement").Show();
                            cneStudent.Text = "";
                        }
                    }
                    else
                    {
                        new MessageBx("Veuillez vérifier le CNE", "Attention").Show();
                    }
                }
                catch (SocketException)
                {
                    new MessageBx("Nous avons rencontré un problème!\nRéessayer plus tard.", "Problème de serveur").Show();
                }
            }
            else
            {
                new MessageBx("Veuillez remplir le champs", "Attention").Show();
            }
        }
Exemplo n.º 26
0
        public string SetupApplication(Guid toolId, Guid applicationKey, string prevToolVersion, string newToolVersion)
        {
            Guid userId = AuthenticateClient("SetupApplication");

            SetupAppObj returnObj = new SetupAppObj();

            try
            {
                // Link user to the application
                WebServiceDAL.LinkUserToApplication(applicationKey, userId);
                WebServiceDAL.UpgradeApplicationVersion(toolId, applicationKey, userId, prevToolVersion, newToolVersion);

                returnObj.IsApplicationUserValid = WebServiceDAL.IsApplicationUserValid(applicationKey, userId);
                returnObj.ToolLatestVersion      = WebServiceDAL.GetLatestToolVersion(toolId);
                returnObj.IsToolValid            = WebServiceDAL.IsToolValid(toolId, newToolVersion);

                if (returnObj.IsApplicationUserValid && returnObj.IsToolValid)
                {
                    returnObj.IsUserAllowedToUseThisTool = WebServiceDAL.IsUserAllowedToUseThisTool(toolId, userId);
                }

                if (returnObj.IsApplicationUserValid && returnObj.IsToolValid && returnObj.IsUserAllowedToUseThisTool)
                {
                    returnObj.CommunityData = WebServiceDAL.GetUserCommunityData(toolId, userId);

                    Int64 encryptionKeyId = WebServiceDAL.GetUserEncryptionKeyId(userId);

                    if (encryptionKeyId == 0)
                    {
                        returnObj.EncryptionKeysExists = WebServiceDAL.CreateUserEncryptionKey(userId, Credentials.Password);
                        encryptionKeyId = WebServiceDAL.GetUserEncryptionKeyId(userId);
                    }
                    else
                    {
                        returnObj.EncryptionKeysExists = true;
                    }

                    if (encryptionKeyId != 0)
                    {
                        DataTable encryptionKeys = WebServiceDAL.GetUserEncryptionKeys(encryptionKeyId);
                        string    serverKey      = "";
                        string    clientKey      = "";
                        try
                        {
                            serverKey = Encryption.DecryptString(UtilitiesBLL.DecryptEncryptionKeyHash(encryptionKeys.Rows[0]["ServerKey"].ToString()), Credentials.Password);
                            clientKey = Encryption.DecryptString(UtilitiesBLL.DecryptEncryptionKeyHash(encryptionKeys.Rows[0]["ClientKey"].ToString()), Credentials.Password);
                        }
                        catch (Exception ex)
                        {
                            WebServiceDAL.StoreException("Webservice", "SetupApplication - Keys encryption", ex);
                            // ServerKey or ClientKey is null/empty or something else went wrong when decrypting
                            // Therefore, create new keys
                            serverKey = UtilitiesBLL.CreateEncryptionKeyHash(Encryption.EncryptString(RandomPassword.Generate(15, 20), Credentials.Password));
                            clientKey = RandomPassword.Generate(15, 20);
                            returnObj.EncryptionKeysExists = WebServiceDAL.UpdateEncryptionKey(encryptionKeyId, serverKey, UtilitiesBLL.CreateEncryptionKeyHash(Encryption.EncryptString(clientKey, Credentials.Password)));
                            // Delete all saved passwords
                            WebServiceDAL.DeleteUserUniverseCredentialsPassword(userId);
                            serverKey = null;
                        }
                        if (!string.IsNullOrEmpty(clientKey))
                        {
                            returnObj.ClientEncryptionKey = clientKey;
                        }
                        else
                        {
                            throw new Exception("ClientKey cannot be empty or null");
                        }

                        if (!string.IsNullOrEmpty(serverKey))
                        {
                            returnObj.CredentialsList = WebServiceDAL.GetUserUniversesAccounts(userId, serverKey, clientKey);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WebServiceDAL.StoreException("Webservice", "SetupApplication", ex);
                returnObj.Error        = true;
                returnObj.ErrorMessage = ex.Message;
            }

            return(SerializeDeserializeObject.SerializeObject <SetupAppObj>(returnObj));;
        }
Exemplo n.º 27
0
        public override void run()
        {
            int size = 1024;

            byte[] buffer = new byte[size];
            while (true)
            {
                try
                {
                    buffer = new byte[1024];
                    size   = socket.Receive(buffer);
                    Console.WriteLine(size);
                    Array.Resize(ref buffer, size);
                    Request request = (Request)SerializeDeserializeObject.Deserialize(buffer);

                    Object answer         = null;
                    int    nbRowsAffected = 0;
                    string CNE;
                    Branch branch;
                    switch (request.Type)
                    {
                    case RequestType.AddStudent:
                        Student student = (Student)request.Data;
                        Console.WriteLine("Adding student ...");
                        nbRowsAffected = connection.addStudent(student);
                        if (nbRowsAffected > 0)
                        {
                            answer = true;
                        }
                        else
                        {
                            answer = false;
                        }
                        break;

                    case RequestType.UpdateStudent:
                        Student data = (Student)request.Data;
                        Console.WriteLine("Updating student ...");
                        nbRowsAffected = connection.updateStudent(data);
                        if (nbRowsAffected > 0)
                        {
                            answer = true;
                        }
                        else
                        {
                            answer = false;
                        }
                        break;

                    case RequestType.GetOneStudnet:
                        Console.WriteLine("getting one Student");
                        CNE    = (string)request.Data;
                        answer = connection.getStudent(CNE);
                        break;

                    case RequestType.GetAllStudnets:
                        Console.WriteLine("getting all students");
                        answer = connection.getAllStudents();
                        break;

                    case RequestType.GetStudentByBranch:
                        Console.WriteLine("getting all students grouping by branch");
                        answer = connection.getStudentsByBranch();
                        break;

                    case RequestType.DeleteStudent:
                        Console.WriteLine("Deleting the student");
                        CNE            = (string)request.Data;
                        nbRowsAffected = connection.deleteStudent(CNE);
                        if (nbRowsAffected > 0)
                        {
                            answer = true;
                        }
                        else
                        {
                            answer = false;
                        }
                        break;

                    case RequestType.AddBranch:
                        Console.WriteLine("Adding a branch");
                        branch         = (Branch)request.Data;
                        nbRowsAffected = connection.addBranch(branch);
                        if (nbRowsAffected > 0)
                        {
                            answer = true;
                        }
                        else
                        {
                            answer = false;
                        }
                        break;

                    case RequestType.UpdateBranch:
                        Console.WriteLine("Updating a branch");
                        branch         = (Branch)request.Data;
                        nbRowsAffected = connection.updateBranch(branch);
                        if (nbRowsAffected > 0)
                        {
                            answer = true;
                        }
                        else
                        {
                            answer = false;
                        }
                        break;

                    case RequestType.GetAllBranches:
                        Console.WriteLine("Getting all branches");
                        answer = connection.getAllBranchs();
                        break;

                    case RequestType.DeleteBranch:
                        Console.WriteLine("Deleting the branch");
                        int ID = (int)request.Data;
                        nbRowsAffected = connection.deleteBranch(ID);
                        if (nbRowsAffected > 0)
                        {
                            answer = true;
                        }
                        else
                        {
                            answer = false;
                        }
                        break;

                    case RequestType.GetStatics:
                        Console.WriteLine("Getting the statistics");
                        answer = connection.getStatistics();
                        break;

                    case RequestType.CheckUser:
                        Console.WriteLine("Getting the user");
                        User user = request.Data as User;
                        answer = connection.CheckUser(user);

                        break;

                    case RequestType.UpdateUser:
                        Console.WriteLine("Updating the user");
                        User userUpadte = request.Data as User;
                        nbRowsAffected = connection.UpdateUser(userUpadte);
                        if (nbRowsAffected > 0)
                        {
                            answer = true;
                        }
                        else
                        {
                            answer = false;
                        }
                        break;
                    }

                    byte[] bufferAnswer = SerializeDeserializeObject.Serialize(answer);

                    socket.Send(bufferAnswer);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);

                    /*socket.Close();
                     * socket.Dispose();*/
                    break;
                }
            }
        }