//

        public Tank CreateTank(string name)
        {
            Tank tank;
            var  result = name.Replace(" ", "").ToLower();

            if (result == "tiger")
            {
                tank = new Tiger();
            }
            else if (result == "oi")
            {
                tank = new OI();
            }
            else if (result == "renault")
            {
                tank = new Renault();
            }
            else if (result == "stg")
            {
                tank = new STG();
            }
            else if (result == "churchill")
            {
                tank = new Churchill();
            }
            else
            {
                return(null);
            }
            return(tank);
        }
Exemple #2
0
        private async void btn_Connection_Click(object sender, EventArgs e)
        {
            oSTG = new STG();
            oSTG.data = new Hashtable();

            CUT user_CUT = new CUT();
            CUC user_CUC = new CUC();

            if(string.IsNullOrEmpty(txt_Login.Text) || string.IsNullOrEmpty(txt_PWD.Text))
            {
                MessageBox.Show("Veuillez remplir tous les champs.", "Erreur", MessageBoxButtons.OK);
            }
            else
            {
                STG stg_logging = await user_CUC.sendMessage(user_CUT.login(oSTG, txt_Login.Text, txt_PWD.Text));
                bool user_logged = stg_logging.Status_op;

                if (user_logged)
                {
                    Form form1 = new frm_Generator();
                    form1.Show();
                }
                else if (CUC.oSTG.Info == null)
                {
                    MessageBox.Show("Impossible de se connecter au serveur", "Erreur", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show(CUC.oSTG.Info, "Erreur", MessageBoxButtons.OK);
                }
            }
        }
Exemple #3
0
        private void btnAddClass_Click(object sender, EventArgs e)
        {
            Comboitem subject = cmbSubjects.SelectedItem as Comboitem;
            Comboitem teacher = cmbTeachers.SelectedItem as Comboitem;
            Comboitem group   = cmbGroups.SelectedItem as Comboitem;

            STG stg = db.STGs.FirstOrDefault(s => s.SubjectID == subject.Value &&
                                             s.GroupID == group.Value);

            if (stg != null)
            {
                MessageBox.Show($"Class with this properties has already exists", "Creation Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            STG newstg = new STG
            {
                SubjectID = subject.Value,
                TeacherID = teacher.Value,
                GroupID   = group.Value
            };

            db.STGs.Add(newstg);
            db.SaveChanges();
            updateClassesDataGrid();
            MessageBox.Show($"Class created successfully", "Creation Success",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #4
0
        private void click_validate_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.email.Text) && !string.IsNullOrEmpty(this.password.Text))
            {
                this.msg.data    = new object[2];
                this.msg.data[0] = this.email.Text;
                this.msg.data[1] = this.password.Text;

                this.msg.operationName = "auth";

                try
                {
                    this.msg = cut.checkData(this.serviceContract.m_service(cut.checkData(this.msg)));
                }
                catch
                {
                    this.connect.Text = "Erreur de connexion";
                }

                if (this.msg.info == "13, user connected")
                {
                    this.connect.Text = "Connected";
                    this.token.Text   = "Token : " + this.msg.tokenUser;
                }
            }
        }
        public STG GetAll(STG message, string username)
        {
            STG response = new STG()
            {
                statut_op     = true,
                info          = "",
                data          = new object[0] {
                },
                operationname = message.operationname,
                tokenApp      = "",
                tokenUser     = message.tokenUser
            };

            List <File> files = mappingFiles.SelectAllFile(username);

            response.data = new object[files.Count * 2];

            for (int i = 0; i < files.Count; i++)
            {
                response.data[i * 2]     = files[i].Filename;
                response.data[i * 2 + 1] = files[i].State;
            }

            return(response);
        }
        // Logout by removing token user
        public STG Logout(STG message)
        {
            STG response = new STG()
            {
                statut_op     = false,
                info          = "",
                data          = new object[0] {
                },
                operationname = message.operationname,
                tokenApp      = "",
                tokenUser     = message.tokenUser
            };

            // Verify opetion name
            if (message.operationname != "logout")
            {
                response.info = "Wrong operation name";
                return(response);
            }

            // Put new tokenUser in database
            if (mappingUsers.RemoveTokenUser(message.tokenUser) == 0)
            {
                response.info = "Unknown token user";
                return(response);
            }

            response.statut_op = true;
            response.info      = "logout";
            response.tokenUser = "";
            return(response);
        }
Exemple #7
0
        protected override IMilitaryVehicle Create(string name)
        {
            Tank tank;
            var  result = name.Replace(" ", "").ToLower();

            if (result == "tiger")
            {
                tank = new Tiger();
            }
            else if (result == "oi")
            {
                tank = new OI();
            }
            else if (result == "renault")
            {
                tank = new Renault();
            }
            else if (result == "stg")
            {
                tank = new STG();
            }
            else if (result == "churchill")
            {
                tank = new Churchill();
            }
            else
            {
                return(null);
            }
            //tank.Drive();
            return(tank);
            //return new Tiger();
        }
Exemple #8
0
        public STG dechiffrer(STG oSTG, int oSampleSize)
        {
            oSTG.Operationname = "GpcsDecrypt_Dechiffrer";
            oSTG.data.Remove("sampleSize");
            oSTG.data.Add("sampleSize", oSampleSize);

            return oSTG;
        }
Exemple #9
0
 public STG m_service(STG msg)
 {
     if (checkToken(msg).statut_op)
     {
         this.msg = cl_cam.resolveService(msg);
     }
     return(this.msg);
 }
Exemple #10
0
        public STG login(STG oSTG, string oLogin, string oPWD)
        {
            oSTG.Operationname = "GpcsUser_ConnectionUser";
            oSTG.data.Add("login", oLogin);
            oSTG.data.Add("password", oPWD);

            return oSTG;
        }
Exemple #11
0
        static void Main(string[] args)
        {
            STG msge = new STG();

            msge.op_name = "test";
            string julien = msge.op_name.ToString();

            msge.op_name = "test";
        }
        public STG Login(STG message)
        {
            STG response = new STG()
            {
                statut_op     = false,
                info          = "",
                data          = new object[0] {
                },
                operationname = message.operationname,
                tokenApp      = "",
                tokenUser     = message.tokenUser
            };

            // Verify opetion name
            if (message.operationname != "login")
            {
                response.info = "Wrong operation name";
                return(response);
            }

            // Get User
            List <User> users = mappingUsers.SelectByUsername(message.data[0].ToString());

            // Can't find user
            if (users.Count == 0)
            {
                response.info = "Can't find user";
                return(response);
            }

            User user = users[0];

            // Wrong password
            if (!Hasher.Verify(message.data[1].ToString(), user.Password))
            {
                response.statut_op = false;
                response.info      = "Wrong password";
                return(response);
            }

            string tokenUser = Convert.ToBase64String(Guid.NewGuid().ToByteArray());

            // Put new tokenUser in database
            if (mappingUsers.UpdateTokenUser(user.ID, tokenUser) == 0)
            {
                response.info = "Error while updating user";
                return(response);
            }

            // Return message with the tokenUser
            response.statut_op = true;
            response.info      = "logged";
            response.tokenUser = tokenUser;

            return(response);
        }
 public void StoreFileResult(string file, string user, STG message)
 {
     mappingFiles.FinishBF(new File(
                               file,
                               user,
                               "finish",
                               message.data[2].ToString(),
                               message.data[1].ToString(),
                               double.Parse(message.data[3].ToString()),
                               message.data[4].ToString()
                               ));
 }
        public STG Signup(STG message)
        {
            string username = message.data[0].ToString();
            string email    = message.data[1].ToString();
            string password = message.data[2].ToString();

            STG response = new STG()
            {
                statut_op     = false,
                info          = "",
                data          = new object[0] {
                },
                operationname = message.operationname,
                tokenApp      = "",
                tokenUser     = message.tokenUser
            };

            // Verify opetion name
            if (message.operationname != "signup")
            {
                response.info = "Wrong operation name";
                return(response);
            }

            // Check if username is taken
            if (mappingUsers.UsernameExist(username))
            {
                response.info = "Username already exist";
                return(response);
            }

            // Check if email is taken
            if (mappingUsers.EmailExist(email))
            {
                response.info = "Email already exist";
                return(response);
            }

            string hash = Hasher.Hash(password);

            User user = new User(username, email, hash);

            if (mappingUsers.Insert(user) == 0)
            {
                response.info = "Error while creating user";
                return(response);
            }

            response.statut_op = true;
            response.info      = "registered";
            return(response);
        }
Exemple #15
0
        //Verifie les données Avant/Après server

        public STG checkData(STG msg)
        {
            if (msg.data[0].GetType() == typeof(object[]))
            {
                msg.statut_op = true;
            }
            else
            {
                msg.statut_op = false;
            }

            return(msg);
        }
 public STG send(STG message)
 {
     try
     {
         message.tokenApp = tokenApp;
         STG result = services.m_service(message);
         result.Print();
         return(result);
     }
     catch
     {
         channelFactory.Abort();
         throw;
     }
 }
Exemple #17
0
        public static STG checkPrivilege(STG msg)
        {
            if (msg.tokenApll != "GEN_WCF")
            {
                msg.statut_op = false;
                msg.info      = "error tokenApll";
            }
            else
            {
                msg.statut_op = true;
                msg.info      = "13, ok";
            }

            return(msg);
        }
        private void Dt_Tick(object sender, EventArgs e)
        {
            ((DispatcherTimer)sender).Stop();

            DoubleAnimation da = new DoubleAnimation()
            {
                From     = 1,
                To       = 0,
                Duration = TimeSpan.FromSeconds(2)
            };

            Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));
            st.Children.Add(da);
            st.Completed += St_Completed1;
            STG.BeginStoryboard(st);
        }
        public static string createSession(STG msg, cl_cmp_session oCmpSession, cl_cad oCad)
        {
            byte[] time  = BitConverter.GetBytes(DateTime.UtcNow.ToBinary());
            byte[] key   = Guid.NewGuid().ToByteArray();
            string token = Convert.ToBase64String(time.Concat(key).ToArray());

            if (!checkSession(msg, oCmpSession, oCad))
            {
                oCad.ActionRows(oCmpSession.createSession(token, DateTime.UtcNow.AddHours(24), msg.data[0].ToString(), DateTime.UtcNow));
            }
            else
            {
                Console.WriteLine("Session already exist");
            }

            Console.WriteLine("Session started");
            return(token);
        }
Exemple #20
0
        public static STG resolveService(STG msg)
        {
            if (msg.operationName == "auth")
            {
                msg = new cl_cm_auth().auth(msg);
            }
            else if (msg.operationName == "decode")
            {
                msg = new cl_cm_decode().decode(msg);
            }
            else
            {
                msg.statut_op = false;
                msg.info      = "error operationName";
            }

            return(msg);
        }
Exemple #21
0
        public Form1(IServiceContract serviceContract)
        {
            InitializeComponent();
            this.serviceContract = serviceContract;
            this.cut             = new dll_cut();
            this.msg             = new STG
            {
                tokenApll = "GEN_WCF",
            };

            this.file.Items.Add("P1E.txt");
            this.file.Items.Add("P1G.txt");
            this.file.Items.Add("P1A.txt");
            this.file.Items.Add("P1B.txt");
            this.file.Items.Add("P1D.txt");
            this.file.Items.Add("P1F.txt");
            this.file.Items.Add("P1C.txt");
        }
Exemple #22
0
        public async Task<STG> sendMessage(STG oSTG)
        {
            oSTG.TokenApp = "Generator";

            try
            {
                Couche_middleware.IcomposantService myService = new Couche_middleware.IcomposantServiceClient();
                Task<STG> Temp_Task = myService.connectionAsync(oSTG);
                oSTG = await Temp_Task;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OK);
            }
            
            CUC.oSTG = oSTG;

            return oSTG;
        }
Exemple #23
0
        public BruteForce(STG message, string username)
        {
            file = message.data[0].ToString();
            text = message.data[1].ToString();
            user = username;
            jee  = new JEE();
            ServicePointManager.DefaultConnectionLimit = 1000;

            files.createFileInDatabase(file, user);

            if (stopBFs.ContainsKey(file))
            {
                stopBFs[file] = false;
            }
            else
            {
                stopBFs.Add(file, false);
            }
        }
Exemple #24
0
        /// <summary>
        /// Send files to decrypt platform
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSendFiles_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.displayResultsPage.comboBox.Items.Clear();

            STG message = new STG()
            {
                statut_op     = true,
                info          = "file",
                data          = new object[] { Path.GetFileName(filename), FileContent },
                operationname = "bruteForce",
                tokenApp      = MainWindow.tokenApp,
                tokenUser     = MainWindow.tokenUser
            };

            STG message2 = new STG()
            {
                statut_op     = true,
                info          = "getAll",
                data          = new object[] {},
                operationname = "list",
                tokenApp      = MainWindow.tokenApp,
                tokenUser     = MainWindow.tokenUser
            };

            //Verif that there is a file
            if (boxBrowse.Text == "")
            {
                noFileFounded.Visibility = Visibility.Visible;
            }
            else
            {
                STG result  = MainWindow.services.m_service(message);
                STG result2 = MainWindow.services.m_service(message2);

                for (int i = 0; i < result2.data.Length; i += 2)
                {
                    MainWindow.displayResultsPage.comboBox.Items.Add(result2.data[i]);
                }

                this.NavigationService.Navigate(MainWindow.displayResultsPage);
            }
        }
        public STG decode(STG msg)
        {
            Console.WriteLine("Demande de service 'decode'");

            string text = System.IO.File.ReadAllText(".\\" + msg.data[2]);

            char[] key = //fjuiop
            {
                'f',
                'j',
                'u',
                'i',
                'o',
                'a'
            };



            if (!string.IsNullOrEmpty(msg.data[0].ToString()))
            {
                key = msg.data[0].ToString().ToCharArray();
            }

            int start = 5;

            for (int i = start; i < 6; i++)
            {
                do
                {
                    key[i] = findAlpha(key[i]);
                    if (new string(key).Equals("fjuioz"))
                    {
                        msg.info = "13, decoded";
                    }
                    return(sendMsg(text, new string(key), msg));
                } while (!key[i].Equals("z"));
            }

            msg.info = "13, decode";

            return(sendMsg(text, new string(key), msg));
        }
        public STG sendMsg(string text, string key, STG msg)
        {
            using (System.IO.StreamWriter file = new System.IO.StreamWriter("./" + msg.data[2] + "Decrypt.txt", true))
            {
                file.WriteLine(deXor(text, key));
                file.WriteLine(key);
                file.WriteLine(msg.data[0].ToString());
                file.WriteLine("________________________________________________________________________________________________________________");

                //Console.WriteLine("key: " + key);
                //Console.WriteLine("content: " + deXor(text, key));
                //Console.WriteLine("fileName: " + msg.data[2]);

                msg.data[0] = key;              // key
                msg.data[1] = deXor(text, key); // content
                msg.data[2] = msg.data[2];      // file

                return(msg);
            }
        }
Exemple #27
0
        private void seeResultsbtn_Click(object sender, RoutedEventArgs e)
        {
            STG message = new STG()
            {
                statut_op     = true,
                info          = "",
                data          = new object[] { },
                operationname = "list",
                tokenApp      = MainWindow.tokenApp,
                tokenUser     = MainWindow.tokenUser
            };

            STG result = MainWindow.services.m_service(message);

            for (int i = 0; i < result.data.Length; i += 2)
            {
                MainWindow.displayResultsPage.comboBox.Items.Add(result.data[i]);
            }
            this.NavigationService.Navigate(MainWindow.displayResultsPage);
        }
Exemple #28
0
        /// <summary>
        /// When another file is selected see the results and the progress
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBox.SelectedIndex == -1)
            {
                return;
            }

            String filenameSelected = comboBox.SelectedItem.ToString();

            STG message = new STG()
            {
                statut_op     = true,
                info          = "",
                data          = new object[] { filenameSelected },
                operationname = "result",
                tokenApp      = MainWindow.tokenApp,
                tokenUser     = MainWindow.tokenUser
            };

            STG result = MainWindow.services.m_service(message);


            statusLabel.Visibility = Visibility.Visible;

            statusLabel.Content = result.info;

            if (result.info == "finish")
            {
                keyBox.Text         = result.data[1].ToString();
                contentBox.Text     = result.data[2].ToString();
                pourcentageBox.Text = result.data[3].ToString();
                EmailBox.Text       = result.data[4].ToString();
            }
            else if (result.info == "progress")
            {
                keyBox.Clear();
                contentBox.Clear();
                pourcentageBox.Clear();
                EmailBox.Clear();
            }
        }
        /// <summary>
        /// Send and verify login informations --> redirection to sendFilesPage
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                STG message = new STG()
                {
                    statut_op     = true,
                    info          = "connection",
                    data          = new object[] { loginBox.Text, passwordBox.Password.ToString() },
                    operationname = "login",
                    tokenApp      = MainWindow.tokenApp
                };

                //Send login informations
                STG result = MainWindow.services.m_service(message);

                //Verif of login informations
                if (result.statut_op == false && result.info == "Can't find user")
                {
                    wrongLogin.Visibility = Visibility.Visible;
                }
                else if (result.statut_op == false && result.info == "Wrong password")
                {
                    wrongPassword.Visibility = Visibility.Visible;
                }
                else
                {
                    MainWindow.userConnected = message.data[0].ToString();

                    MainWindow.sendFilesPage.connectedUser.Content      = MainWindow.userConnected;
                    MainWindow.displayResultsPage.connectedUser.Content = MainWindow.userConnected;
                    MainWindow.tokenUser = result.tokenUser;
                    this.NavigationService.Navigate(MainWindow.sendFilesPage);
                }
            }
            catch
            {
                MainWindow.channelFactory.Abort();
                throw;
            }
        }
        /// <summary>
        /// Exit method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            STG message = new STG()
            {
                statut_op     = true,
                info          = "signOut",
                data          = new object[] { },
                operationname = "logout",
                tokenApp      = MainWindow.tokenApp
            };

            MessageBoxResult resultat;

            resultat = MessageBox.Show("Do you really want to close the App ?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (resultat == MessageBoxResult.Yes)
            {
                STG result = MainWindow.services.m_service(message);
                Application.Current.Shutdown();
            }
        }
Exemple #31
0
        /// <summary>
        /// Refresh the page to see if there is changes on the progress of the files
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void refreshBtn_Click(object sender, RoutedEventArgs e)
        {
            comboBox.Items.Clear();

            STG message = new STG()
            {
                statut_op     = true,
                info          = "",
                data          = new object[] { },
                operationname = "list",
                tokenApp      = MainWindow.tokenApp,
                tokenUser     = MainWindow.tokenUser
            };

            STG result = MainWindow.services.m_service(message);

            for (int i = 0; i < result.data.Length; i += 2)
            {
                comboBox.Items.Add(result.data[i]);
            }
        }
        public STG GetResult(STG message, string username)
        {
            STG response = new STG()
            {
                statut_op     = false,
                info          = "",
                data          = new object[0] {
                },
                operationname = message.operationname,
                tokenApp      = "",
                tokenUser     = message.tokenUser
            };

            List <File> files = mappingFiles.SelectByUserAndFile(message.data[0].ToString(), username);

            if (files.Count == 0)
            {
                response.info = "Can't find file " + message.data[0].ToString();
                return(response);
            }

            File file = files[0];

            response.statut_op = true;
            response.info      = file.State;

            if (file.State == "finish")
            {
                response.data = new object[]
                {
                    file.Filename,
                    file.Key,
                    file.Text,
                    file.Percent,
                    file.Email
                };
            }

            return(response);
        }
Exemple #33
0
        /// <summary>
        /// Validate inscription.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInscription_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                STG message = new STG()
                {
                    statut_op     = true,
                    info          = "inscription",
                    data          = new object[] { inscrLoginBox.Text, inscrMailBox.Text, inscrPasswordBox.Password.ToString() },
                    operationname = "signup",
                    tokenApp      = MainWindow.tokenApp
                };

                STG result = MainWindow.services.m_service(message);

                //if password are different show error message
                if (inscrPasswordBox.Password.ToString() != inscrConfPasswordBox.Password.ToString())
                {
                    passwordDifferent.Visibility  = Visibility.Visible;
                    passwordDifferent1.Visibility = Visibility.Visible;
                }
                else if (result.statut_op == false && result.info == "Username already exist")
                {
                    wrongLogin.Visibility = Visibility.Visible;
                }
                else if (result.statut_op == false && result.info == "Email already exist")
                {
                    wrongEmail.Visibility = Visibility.Visible;
                }
                else
                {
                    this.NavigationService.Navigate(MainWindow.connexionPage);
                }
            }
            catch
            {
                MainWindow.channelFactory.Abort();
                throw;
            }
        }
Exemple #34
0
        /// <summary>
        /// Log out function and redirect to log in page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void signOutBtn_Click(object sender, RoutedEventArgs e)
        {
            STG message = new STG()
            {
                statut_op     = true,
                info          = "signOut",
                data          = new object[] { },
                operationname = "logout",
                tokenApp      = MainWindow.tokenApp,
                tokenUser     = MainWindow.tokenUser
            };

            MessageBoxResult resultat;

            resultat = MessageBox.Show("Do you really want to sign out the App ?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (resultat == MessageBoxResult.Yes)
            {
                this.NavigationService.Navigate(MainWindow.connexionPage);
                STG result = MainWindow.services.m_service(message);
            }
        }
Exemple #35
0
        public void createReport(STG oSTG)
        {
            if(File.Exists(pdf_path))
            {
                File.Delete(pdf_path);
            }

            Document pdf_document = new Document();
            PdfWriter.GetInstance(pdf_document, new FileStream(pdf_path, FileMode.Create));
            pdf_document.Open();

            var pdf_font_black = FontFactory.GetFont("Arial", 12, iTextSharp.text.BaseColor.BLACK);
            var pdf_font_black_text = FontFactory.GetFont("Arial", 10, iTextSharp.text.BaseColor.BLACK);
            var pdf_font_white = FontFactory.GetFont("Arial", 16, iTextSharp.text.BaseColor.WHITE);

            pdf_document.AddTitle("Rapport de déchiffrement");
            pdf_document.Add(new Paragraph("Rapport de déchiffrement des fichiers édité par " + oSTG.data["login"] + ".", pdf_font_black));
            pdf_document.Add(new Paragraph("Nombre de fichiers traités : " + oSTG.files.Count.ToString(), pdf_font_black));
            pdf_document.Add(new Paragraph("Clé de déchiffrement : " + (string)oSTG.data["cle"], pdf_font_black));
            pdf_document.Add(new Paragraph("\n"));

            PdfPTable pdf_table_files = new PdfPTable(2);

            PdfPCell pdf_cell_Dechiffre = new PdfPCell(new Paragraph("Fichier(s) déchiffré(s)", pdf_font_white));
            pdf_cell_Dechiffre.BackgroundColor = iTextSharp.text.BaseColor.DARK_GRAY;
            pdf_cell_Dechiffre.Colspan = 2;
            pdf_table_files.AddCell(pdf_cell_Dechiffre);

            foreach (DictionaryEntry key in oSTG.files)
            {
                char[] delimiterChars = { ';' };

                string key_raw = (string)key.Key;
                string[] key_words = key_raw.Split(delimiterChars);

                PdfPCell pdf_cell_Fichier = new PdfPCell(new Paragraph("Fichier", pdf_font_black));
                pdf_cell_Fichier.BackgroundColor = iTextSharp.text.BaseColor.LIGHT_GRAY;
                pdf_cell_Fichier.Colspan = 1;
                pdf_table_files.AddCell(pdf_cell_Fichier);

                PdfPCell pdf_cell_Ratio = new PdfPCell(new Paragraph("Ratio de confiance", pdf_font_black));
                pdf_cell_Ratio.BackgroundColor = iTextSharp.text.BaseColor.LIGHT_GRAY;
                pdf_cell_Ratio.Colspan = 1;
                pdf_table_files.AddCell(pdf_cell_Ratio);

                pdf_table_files.AddCell(new Paragraph(System.IO.Path.GetFileNameWithoutExtension(key_words[0]), pdf_font_black));
                pdf_table_files.AddCell(new Paragraph(key_words[1], pdf_font_black));

                PdfPCell pdf_cell_Texte = new PdfPCell(new Paragraph("Texte", pdf_font_black));
                pdf_cell_Texte.BackgroundColor = iTextSharp.text.BaseColor.LIGHT_GRAY;
                pdf_cell_Texte.Colspan = 2;
                pdf_table_files.AddCell(pdf_cell_Texte);

                PdfPCell pdf_cell_Files_Texte = new PdfPCell(new Paragraph((string)key.Value, pdf_font_black_text));
                pdf_cell_Files_Texte.Colspan = 2;
                pdf_table_files.AddCell(pdf_cell_Files_Texte);
            }

            pdf_document.Add(pdf_table_files);

            pdf_document.Add(new Paragraph("\n"));
            pdf_document.Add(new Paragraph("Adresse Email : " + oSTG.data["mail"]));

            pdf_document.Close();
        }
Exemple #36
0
        public void sendEmail(STG oSTG)
        {
            createReport(oSTG);

            MessageBox.Show("Rapport généré avec succès.");

            Process.Start(pdf_path);

            if (MessageBox.Show("Voulez-vous envoyer le rapport par Email ?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string Mail_From = "*****@*****.**";
                string Mail_To = "*****@*****.**";
                string Mail_Subject = oSTG.TokenApp + " - Résultats du déchiffrement";
                string Mail_Body = "Ci-joint le rapport de déchiffrement des fichiers.";

                SmtpClient Mail_Smtp = new SmtpClient("smtp.gmail.com", 465);
                Mail_Smtp.EnableSsl = true;
                Mail_Smtp.Credentials = new NetworkCredential("*****@*****.**", "password");

                MailMessage oMail = new MailMessage(Mail_From, Mail_To, Mail_Subject, Mail_Body);

                oMail.Attachments.Add(new Attachment(pdf_path));

                try
                {
                    Mail_Smtp.Send(oMail);
                    MessageBox.Show("Email envoyé.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erreur d'envoi de l'Email : " + ex.Message);
                }
            }
        }