예제 #1
0
 public STG insertToken(STG oSTG)
 {
     oSTG.SetData("query", "UPDATE t_user "+
                 "SET [use_token] = '" + oSTG.TokenUser + "' "+
                 "WHERE use_login = '******' ;");
     return oSTG;
 }
예제 #2
0
 public STG checkToken(STG oSTG)
 {
     oSTG.SetData("query", "SELECT * "+
                           "FROM t_user "+
                           "WHERE use_token = '"+ oSTG.TokenUser + "';");
     return oSTG;
 }
예제 #3
0
        public STG executeCUDQuery(STG oSTG)
        {
            if (oSTG.GetData("query") != null) {
                SqlCommand sqlCommand = new SqlCommand((string)oSTG.GetData("query"), this.sqlConn);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

                oSTG.SetData("sqldatareader", sqlDataReader);
            }

            return oSTG;
        }
예제 #4
0
        public STG connection(STG oSTG)
        {
            oSTG.Info = "arrivée sur le serveur";
            oSTG.SetData("test", "this is a test");
            if (oSTG.TokenApp == "Generator")
            {
                if (!string.IsNullOrEmpty(oSTG.Operationname))
                {
                    string[] operationSplit = oSTG.Operationname.Split(new char[] { '_' });
                    if (operationSplit.Length >= 2)
                    {
                        string nomClasse = operationSplit[0];
                        string nomMethode = operationSplit[1];
                        if (nomClasse == "GpcsUser")
                        {
                            GpcsUser oGpcsUser = new GpcsUser();
                            oSTG.Operationname = nomMethode;
                            oSTG = oGpcsUser.ConnectionUser(oSTG);
                        }
                        else if (nomClasse == "GpcsDecrypt")
                        {
                            GpcsDecrypt oGpcsDecrypt = new GpcsDecrypt();
                            oSTG.Operationname = nomMethode;
                            oSTG = oGpcsDecrypt.Decrypter(oSTG);
                        }
                        else
                        {
                            oSTG.Status_op = false;
                            oSTG.Info = "Le nom de l'opération n'est pas valide";
                        }
                    }
                    else
                    {
                        oSTG.Status_op = false;
                        oSTG.Info = "Le nom de l'opération n'est pas valide";
                    }
                }
                else
                {
                    oSTG.Status_op = false;
                    oSTG.Info = "Le nom de l'opération n'est pas spécifié";
                }

            }
            else
            {
                oSTG.Status_op = false;
                oSTG.Info = "Le token de l'application n'est pas valide";
            }
            oSTG.SetData("sqldatareader", "");
            oSTG.SetData("query", "");
            try
            {
                //oSTG.files.Clear();
            }
            catch (Exception)
            {

            }
            oSTG.SetData("mail", GlobalVariables.mail);
            GlobalVariables.cleTrouve = false;

            return oSTG;
        }
예제 #5
0
 public STG checkUser(STG oSTG)
 {
     oSTG.SetData("query", "select * from dbo.t_user where use_login = '******'and use_pwd = '"+ oSTG.GetData("password") + "'");
     return oSTG;
 }
예제 #6
0
        public STG Execute(STG oSTG)
        {
            Stopwatch sw2 = new Stopwatch();
            sw2.Start();
            Hashtable files = (Hashtable) oSTG.files;
            int sampleSize = (int)oSTG.GetData("sampleSize");
            bool useSample = true;
            if (sampleSize < 1)
            {
                useSample = false;
            }
            ReceptionSTGClient rSTG = new ReceptionSTGClient();
            foreach (DictionaryEntry key in files)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                //Console.WriteLine("key : "+key.Key/* + " - value :" + key.Value*/);
                string texte = key.Value.ToString();
                string echantillon;
                if (texte.Length > sampleSize && useSample)
                {
                    echantillon = texte.Substring(0, sampleSize);
                }
                else
                {
                    echantillon = texte;
                }
                int taille = echantillon.Length;
                uint[] txt_tab = new uint[taille];
                for (int j = 0; j < taille; j++)
                {
                    txt_tab[j] = (uint)echantillon[j];
                }
                Console.WriteLine("début de l'envoi des messages : ");
                Helper help = new Helper();
                // on lit le fichier
                help.Txt_tab = txt_tab;
                // On compte le nombre de processeur :
                int heart = Environment.ProcessorCount;
                int keyNumber = 10000;
                string file_name = key.Key.ToString();

                //On complete les tableau de start et operations
                help.calculOperation(heart, keyNumber);

                // Création du delegate de traitement :
                paramDelegate dlg = new paramDelegate(help.decrypter);

                // ON commence le traitement sur les 10 000 clés
                Parallel.For(0, heart, i =>
                {
                    help.decrypter(i, file_name);
                });
                sw.Stop();
                Console.WriteLine("messages envoyés : " + help.Envoi + " en " + sw.Elapsed + " secondes");
                if (GlobalVariables.cleTrouve)
                {
                    break;
                }
            }
            if (GlobalVariables.cleTrouve)
            {
                int nb_files = 0;
                foreach (DictionaryEntry key in files)
                {

                    string texte = key.Value.ToString();
                    int taille = texte.Length;
                    uint[] txt_tab = new uint[taille];
                    for (int j = 0; j < taille; j++)
                    {
                        txt_tab[j] = (uint)texte[j];
                    }
                    string txt = EncryptOrDecrypt(txt_tab, GlobalVariables.cle);
                    txt = CleanInvalidXmlChars(txt);
                    rSTG.sendToQueue(txt, key.Key.ToString(), GlobalVariables.cle, false);
                    nb_files++;
                    //Console.WriteLine(txt);
                    //Console.WriteLine("l'email trouve est" + GlobalVariables.mail);
                }
                while (GlobalVariables.nb_callback < nb_files)
                {
                    System.Threading.Thread.Sleep(500);
                }
                oSTG.files.Clear();
                oSTG.SetData("cle", GlobalVariables.cle);
                oSTG.SetData("mail", GlobalVariables.mail);

                oSTG.files = GlobalVariables.files;
            }
            sw2.Stop();
            Console.WriteLine("Temps de traitement total : " + sw2.Elapsed.ToString());
            return oSTG;
        }