Ejemplo n.º 1
0
 public bool reconnexion()
 {
     if (Parametre.URLServeur != string.Empty && Parametre.email != string.Empty && Parametre.motdepasse != string.Empty)
     {
         string reponse = hr.post(Router.url("login"),
                                  "email=" + Parametre.motdepasse +
                                  "&password="******"success"] == false)
         {
             Parametre.API_KEY = Convert.ToString(data["token"]);
         }
         else
         {
             MessageBox.Show("Une erreur c'est produite", Convert.ToString(data["message"]), MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         return(true);
     }
     else
     {
         LoginForm    f1 = new LoginForm();
         DialogResult dr = f1.ShowDialog();
         if (dr == DialogResult.OK)
         {
             Application.Run(new MainForm());
         }
         else
         {
             Application.Exit();
         }
         return(true);
     }
 }
Ejemplo n.º 2
0
        private void StartSendingServer(List <ListViewItem> items)
        {
            string countryCode = txt_country.Text;
            string onlineState = txt_onlineState.Text;
            Thread th          = new Thread(() =>
            {
                foreach (ListViewItem lvi in items)
                {
                    dynamic item     = lvi.Tag;
                    string extension = Path.GetExtension(item["image"]);
                    string fileName  = "image" + extension;
                    if (!Directory.Exists(Globals.CACHE_FOLDER))
                    {
                        Directory.CreateDirectory(Globals.CACHE_FOLDER);
                    }

                    string filePath = Globals.CACHE_FOLDER + @"\" + fileName;
                    DownloadRemoteImageFile(item["image"], filePath);

                    string response = hr.postFile(Globals.API_URL + "/gateway/tube/picture/upload", filePath, "videospicture");

                    if (response != string.Empty)
                    {
                        dynamic blob = ser.DeserializeObject(response);
                        blob         = Encryption.Decrypt(Globals.ENCRYPTION_KEY, blob["d"]);
                        dynamic data = ser.DeserializeObject(blob);

                        if (data["success"])
                        {
                            object dataObj = new
                            {
                                name = item["name"],
                                collectionStreamLink = ser.Serialize(item["parts"]),
                                description          = item["description"],
                                picture_id           = data["picture_id"],
                                source      = item["domain"],
                                countryCode = countryCode,
                                online      = onlineState,
                            };

                            string dataPost = "d=" + HttpUtility.UrlEncode(Encryption.Encrypt(Globals.ENCRYPTION_KEY, ser.Serialize(dataObj)));

                            response = hr.post(Globals.API_URL + "/gateway/tube/post", dataPost);
                            blob     = ser.DeserializeObject(response);
                            response = Encryption.Decrypt(Globals.ENCRYPTION_KEY, blob["d"]);
                            Console.Write(response);
                        }
                    }
                    list_sended.Invoke((MethodInvoker)(() =>
                    {
                        list_sended.Items.Add((ListViewItem)lvi.Clone());
                        lvi.Remove();
                    }));
                }
            });

            th.Start();
        }
        public string Send(string post)
        {
            string response = hr.post(Router.url("send_result"), post);

            return(response);
        }