<repo_name>Clemsx/Csharp<file_sep>/DOT_cardGames_2017/cardGame/cardGame/Hand.cs
using System.Collections.Generic;

namespace cardGame
{
    public class Hand
    {
        private List<List<Card>> _hands;
        private List<bool> _hasPlay;

        public Hand()
        {
            _hands = new List<List<Card>>();
            _hands.Add(new List<Card>());
            _hasPlay = new List<bool>();
            _hasPlay.Add(false);
        }

        public Card Card
        {
            get => default(Card);
            set
            {
            }
        }

        public void SetHasPlay(int index, bool play) => _hasPlay[index] = play;

        public bool GetHasPlay(int index) => _hasPlay[index];

        public void ClearHand(int index = 0)
        {
            if (_hands[0].Count != 0)
                _hands[index].Clear();
        }

        public void TakeCard(Card card, int index = 0) => _hands[index].Add(card);

        public int GetHandValue(int index = 0)
        {
            int value = 0;
            int cardValue;

            foreach (var card in _hands[index])
            {
                cardValue = card.GetValue();
                if (cardValue == 1)
                    value += (value + 11 > 21 ? 1 : 11);
                else
                    value += cardValue;
            }
            return value;
        }

        public string GetDisplaySingleHandMsg(int index = 0, bool dealer = false)
        {
            string msg = "";
            int value = GetHandValue();
            bool first = true;

            msg += value.ToString();
            msg += " (";
            foreach (var card in _hands[0])
            {
                if (first == false)
                    msg += " + ";
                msg += card.GetCardString();
                first = false;
            }
            msg += ")";
            if (dealer)
                return "Dealer's hand:\r\n\t" + msg;
            return "Your hand:\r\n\t" + msg;
        }

        public string GetDisplaySplitHandMsg()
        {
            string msg = "";
            bool first = true;

            for (int i = 0; i < _hands.Count; i++)
            {
                if (first == false)
                    msg += "[Server]: ";
                msg += GetDisplaySingleHandMsg(i);
                first = false;
            }
            return msg;
        }

        public string GetDisplayHandMsg(int index = 0, bool dealer = false)
        {
            if (_hands.Count > 1)
                return GetDisplaySplitHandMsg();
            return GetDisplaySingleHandMsg(index, dealer);
        }

        public string GetDisplayHidHandMsg()
        {
            string msg = "";
            int value = _hands[0][0].GetValue();

            msg += value.ToString() +
                " (" + _hands[0][0].GetCardString() + ")";
            return "Dealer's hand:\r\n\t" + msg;
        }

        public bool IsBusted(int index = 0)
        {
            int value = GetHandValue(index);

            if (value > 21)
                return true;
            else
                return false;
        }

        public List<Card> GetHand(int index = 0)
        {
            if (index < _hands.Count)
                return _hands[index];
            return null;
        }

        public void SplitCard(int index = 0)
        {
            Card card = _hands[index][1];

            _hands[index].RemoveAt(1);
            _hands[index + 1] = new List<Card>();
            _hands[index + 1].Add(card);
            _hasPlay.Add(false);
        }

        public bool IsDoublable(int index)
        {
            if (_hands[index].Count == 2)
                return true;
            return false;
        }

        public bool IsSplittable(int index)
        {
            if (_hands[index][0].GetValue() == _hands[index][1].GetValue())
                return true;
            return false;
        }

        public string GetPlayerActionMsg()
        {
            string msg = "Would you like to HIT, STAND";

            if (IsDoublable(0))
                msg += ", DOUBLE";
            msg += " ?";
            return msg;
        }

        public bool IsEmpty()
        {
            if (_hands[0].Count == 0)
                return true;
            return false;
        }
    }
}<file_sep>/DOT_AREA_2017/DOT_AREA_2017/DOT_AREA_2017/Home/API/Twitter.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mailinblue;
using Vianett.Common.Log4net;
using System.Net;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using Facebook;
using Tweetinvi;
using System.Threading.Tasks;
using Dropbox.Api;
using Dropbox.Api.Files;
using DOT_AREA_2017.Home.Others;

namespace DOT_AREA_2017
{
    public partial class Twitter : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        { 
        }

        protected void ButtonMail_Click(object sender, EventArgs e)
        {
            TwitterPerso TP = new TwitterPerso();

            string message = TextTwitter.InnerText;

            string oauth_consumer_key = TP.getConsumerKey();
            string oauth_consumer_secret = TP.getConsumerSecret();
            string oauth_token = TP.getToken();
            string oauth_token_secret = TP.getTokenSecret();

            ///////////////////////////////////////////////// SEND IN BLUE //////////////////////////////////////////////////
            API sendinBlue = new mailinblue.API("ERWXqjT4mS3aA05V", 5000);    //Optional parameter: Timeout in MS
            Dictionary<string, Object> data = new Dictionary<string, Object>();
            Dictionary<string, string> to = new Dictionary<string, string>();
            to.Add(TextDestination.Text, "to whom!");
            List<string> from_name = new List<string>();
            from_name.Add("<EMAIL>");
            from_name.Add("AREA.NET");
            //List<string> attachment = new List<string>();
            //attachment.Add("https://domain.com/path-to-file/filename1.pdf");
            //attachment.Add("https://domain.com/path-to-file/filename2.jpg");

            data.Add("to", to);
            data.Add("from", from_name);
            data.Add("subject", "AREA send in blue");
            data.Add("html", String.Concat("You post the following message on Twitter : ", message));
            //data.Add("attachment", attachment);
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            Auth.SetUserCredentials(oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret);
            try
            {
                LabelResult.ForeColor = System.Drawing.Color.Green;
                LabelResult.Visible = true;
                LabelResult.Text = "Message posted on Twitter and sended to " + TextDestination.Text;
                Object sendEmail = sendinBlue.send_email(data);
                Tweet.PublishTweet(message);
            }
            catch (Exception ex)
            {
                LabelResult.ForeColor = System.Drawing.Color.Red;
                LabelResult.Visible = true;
                LabelResult.Text = ex.Message;
            }

        }

        protected void ButtonPhone_Click(object sender, EventArgs e)
        {
            string message = TextTwitter.InnerText;

            TwitterPerso TP = new TwitterPerso();
            string oauth_consumer_key = TP.getConsumerKey();
            string oauth_consumer_secret = TP.getConsumerSecret();
            string oauth_token = TP.getToken();
            string oauth_token_secret = TP.getTokenSecret();

            Auth.SetUserCredentials(oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret);

            ///////////////////////////////////////////////// VIANETT //////////////////////////////////////////////////
            string username = "<EMAIL>";
            string password = "<PASSWORD>";
            string msgsender = "33683821203";
            string destinationaddr = string.Concat("33", TextDestination.Text.Remove(0, 1).ToString());
            

            ViaNettSMS s = new ViaNettSMS(username, password);
            ViaNettSMS.Result result;
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            try
            {
                Tweet.PublishTweet(message);
                result = s.sendSMS(msgsender, destinationaddr, String.Concat("You post on Twitter : ", message));
                LabelResult.ForeColor = System.Drawing.Color.Green;
                LabelResult.Visible = true;
                LabelResult.Text = "Message posted on Twitter and sended to " + TextDestination.Text + " !";
            }
            catch (Exception ex)
            {
                LabelResult.ForeColor = System.Drawing.Color.Red;
                LabelResult.Visible = true;
                LabelResult.Text = ex.Message;
            }
        }

        protected void ButtonFb_Click(object sender, EventArgs e)
        {
            string message = TextTwitter.InnerText;


            TwitterPerso TP = new TwitterPerso();
            string oauth_consumer_key = TP.getConsumerKey();
            string oauth_consumer_secret = TP.getConsumerSecret();
            string oauth_token = TP.getToken();
            string oauth_token_secret = TP.getTokenSecret();

            ///////////////////////////////////////////////// FACEBOOK //////////////////////////////////////////////////
            string accessToken = "<KEY>";
            var objFacebookClient = new FacebookClient(accessToken);
            var parameters = new Dictionary<string, object>();
            parameters["message"] = message;
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            Auth.SetUserCredentials(oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret);

            try
            {
                objFacebookClient.Post("feed", parameters);
                Tweet.PublishTweet(message);
            }
            catch (Exception ex)
            {
                LabelResult.ForeColor = System.Drawing.Color.Red;
                LabelResult.Visible = true;
                LabelResult.Text = ex.Message;
            }   
        }

        protected void ButtonTrigger_Click(object sender, EventArgs e)
        {

            TwitterPerso TP = new TwitterPerso();
            string oauth_consumer_key = TP.getConsumerKey();
            string oauth_consumer_secret = TP.getConsumerSecret();
            string oauth_token = TP.getToken();
            string oauth_token_secret = TP.getTokenSecret();

            Auth.SetUserCredentials(oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret);

            var stream = Tweetinvi.Stream.CreateUserStream();
            stream.FollowedUser += (senderr, args) =>
            {
                API sendinBlue = new mailinblue.API("ERWXqjT4mS3aA05V", 5000);    //Optional parameter: Timeout in MS
                Dictionary<string, Object> data = new Dictionary<string, Object>();
                Dictionary<string, string> to = new Dictionary<string, string>();
                to.Add("<EMAIL>", "to whom!");
                List<string> from_name = new List<string>();
                from_name.Add("<EMAIL>");
                from_name.Add("AREA.NET");

                data.Add("to", to);
                data.Add("from", from_name);
                data.Add("subject", "AREA send in blue");
                data.Add("html", "Pop , you followed " + args.User + " on Twitter :)");
                Object sendEmail = sendinBlue.send_email(data);
                Tweet.PublishTweet("I followed " + args.User + " on Twitter");

            };
            stream.StartStream();

        }

        protected void ButtonUnfollowed_Click(object sender, EventArgs e)
        {
            TwitterPerso TP = new TwitterPerso();
            string oauth_consumer_key = TP.getConsumerKey();
            string oauth_consumer_secret = TP.getConsumerSecret();
            string oauth_token = TP.getToken();
            string oauth_token_secret = TP.getTokenSecret();

            Auth.SetUserCredentials(oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret);

            var stream = Tweetinvi.Stream.CreateUserStream();
            stream.UnFollowedUser += (senderr, args) =>
            {
                string message = "I unfollowed " + args.User + " on Twitter :)";
                string accessToken = "<KEY>";
                var objFacebookClient = new FacebookClient(accessToken);
                var parameters = new Dictionary<string, object>();
                parameters["message"] = message;

                try
                {
                    Tweet.PublishTweet(message);
                    objFacebookClient.Post("feed", parameters);
                }
                catch (FacebookApiException ex)
                {
                    Console.WriteLine(ex.Message);
                }

            };
            stream.StartStream();
        }

        protected void ButtonDrop_Click(object sender, EventArgs e)
        {

            TwitterPerso TP = new TwitterPerso();
            string oauth_consumer_key = TP.getConsumerKey();
            string oauth_consumer_secret = TP.getConsumerSecret();
            string oauth_token = TP.getToken();
            string oauth_token_secret = TP.getTokenSecret();

            Auth.SetUserCredentials(oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret);
            int i = 0;
            var stream = Tweetinvi.Stream.CreateUserStream();
            stream.TweetCreatedByMe += (senderr, args) =>
            {
                DropboxClient DBClient = new DropboxClient("<KEY>");
                try
                {
                    string dest = String.Format("D:/Epitech/DOT_AREA_2017/picture({0}).jpg", i++);
                    var media = args.Tweet.Media[0].MediaURLHttps;
                    System.Diagnostics.Debug.WriteLine(media);

                    using (WebClient client = new WebClient())
                    {
                        client.DownloadFile(media, dest);
                    }
                    using (var streams = new MemoryStream(File.ReadAllBytes(dest)))
                    {
                        var response = DBClient.Files.UploadAsync("/area/" + dest, WriteMode.Overwrite.Instance, body: streams);
                        var result = response.Result;
                    }
                }
                catch (Exception ex)
                {
                    LabelResult.Visible = true;
                    LabelResult.Text = ex.Message;
                }
            };
            stream.StartStream();
        }

        protected void ButtonTriggerSMS_Click(object sender, EventArgs e)
        {
            TwitterPerso TP = new TwitterPerso();
            string oauth_consumer_key = TP.getConsumerKey();
            string oauth_consumer_secret = TP.getConsumerSecret();
            string oauth_token = TP.getToken();
            string oauth_token_secret = TP.getTokenSecret();

            string username = "<EMAIL>";
            string password = "<PASSWORD>";
            string msgsender = "33683821203";
            string destinationaddr = string.Concat("33", TextDestination.Text.Remove(0, 1).ToString());


            ViaNettSMS s = new ViaNettSMS(username, password);
            ViaNettSMS.Result result;
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            var stream = Tweetinvi.Stream.CreateUserStream();
            stream.BlockedUser += (senderr, args) =>
            {
                try
                {
                    //Tweet.PublishTweet(message);
                    result = s.sendSMS(msgsender, destinationaddr, "Hey ! Why you blocked " + args.User + " on Twitter :(");
                    LabelResult.ForeColor = System.Drawing.Color.Green;
                    LabelResult.Visible = true;
                    LabelResult.Text = "Message posted on Twitter and sended to " + TextDestination.Text + " !";
                }
                catch (Exception ex)
                {
                    LabelResult.ForeColor = System.Drawing.Color.Red;
                    LabelResult.Visible = true;
                    LabelResult.Text = ex.Message;
                }
            };
            stream.StartStream();
        }
    }
}<file_sep>/DOT_cardGames_2017/cardGame/cardGameTests/PlayerTests.cs
﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DotNetty.Transport.Channels;
using System.Collections.Generic;
using cardGame;

namespace cardGameTests
{
    [TestClass]
    public class PlayerTests
    {
       IChannelHandlerContext ctx;

        [TestMethod]
        public void TestGetName()
        {
            Player player = new Player(ctx, "player_test");

            Assert.AreEqual("player_test", player.GetName());
            Assert.AreNotEqual("blabla", player.GetName());
            Assert.AreNotEqual("zfjzogj", player.GetName());
        }

        [TestMethod]
        public void TestIsBusted()
        {
            Player player = new Player(ctx, "player_test");

            Assert.AreEqual(false, player.IsBusted());
            Assert.AreNotEqual(true, player.IsBusted());
        }
    }
}
<file_sep>/DotNet_epicture_2017/epicture/MainPage.xaml.cs
﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using System.Diagnostics;

namespace epicture
{
    public sealed partial class MainPage : Page
    {
        Imgur_client client_info;
        AutoResetEvent navCompleted;

        public MainPage()
        {
            this.InitializeComponent();
            navCompleted = new AutoResetEvent(false);
        }

        private async void ImgurLogin_OnClick(object sender, RoutedEventArgs e)
        {
            Uri authUri = new Uri("https://api.imgur.com/oauth2/authorize?&client_id=4c87c24c218e973&response_type=code");

            LoginContentFlickr.Visibility = Visibility.Collapsed;
            LoginContent.Visibility = Visibility.Collapsed;
            ImgurLogin.Visibility = Visibility.Visible;

            ImgurLogin.Navigate(authUri);

            await Task.Run(() => { navCompleted.WaitOne(); });

            navCompleted.Reset();
            ImgurLogin.Visibility = Visibility.Collapsed;
            ImgurLogin.Visibility = Visibility.Visible;
        }

        private async void CompletedNav(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            String[] res = args.Uri.ToString().Substring(args.Uri.ToString().IndexOf('#') + 1).Split('=');

            using (HttpClient client = new HttpClient())
            {
                var values = new Dictionary<string, string>
                    {
                        { "client_id", "4c87c24c218e973" },
                        { "client_secret", "<KEY>" },
                        { "grant_type", "authorization_code" },
                        { "code", res[1] }
                    };
                FormUrlEncodedContent content = new FormUrlEncodedContent(values);
                var response = await client.PostAsync("https://api.imgur.com/oauth2/token", content);
                string ret = await response.Content.ReadAsStringAsync();
                Debug.WriteLine(ret);
                client_info = JsonConvert.DeserializeObject<Imgur_client>(ret);
                if (client_info.account_id != 0)
                {
                    this.Frame.Navigate(typeof(HomeImgur), client_info);
                }
                else
                {
                    Imgur_Request request = JsonConvert.DeserializeObject<Imgur_Request>(ret);
                    Response.Text = "Error : " + request.data.error;
                }
            }
        }

        private void FailedNav(object sender, WebViewNavigationFailedEventArgs e)
        {
            Response.Visibility = Visibility.Visible;
            Response.Text = "Failed to navigate Imgur.";
        }

        private void FlickrLogin_OnClick(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(HomeFlickr));
        }

        private void FailedNavFlickr(object sender, WebViewNavigationFailedEventArgs e)
        {
            Response.Visibility = Visibility.Visible;
            Response.Text = "Failed to navigate Flickr.";
        }

        private void CompletedNavFlickr(WebView sender, WebViewNavigationCompletedEventArgs args)
        {

        }
    }


}
<file_sep>/DOT_cardGames_2017/cardGame/cardGame/GameState.cs
﻿namespace cardGame
{
    enum GameState
    {
        LOBBY,
        GAME,
    }
}<file_sep>/DOT_cardGames_2017/cardGame/cardGameTests/CardTests.cs
﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using cardGame;

namespace cardGameTests
{


    [TestClass]
    public class CardTests
    {
        Card cardH1 = new Card(1, cardGame.Suit.HEART);
        Card cardD1 = new Card(1, cardGame.Suit.DIAMOND);
        Card cardS1 = new Card(1, cardGame.Suit.SPADE);
        Card cardC1 = new Card(1, cardGame.Suit.CLUB);

        Card cardH10 = new Card(10, cardGame.Suit.HEART);
        Card cardD10 = new Card(10, cardGame.Suit.DIAMOND);
        Card cardS10 = new Card(10, cardGame.Suit.SPADE);
        Card cardC10 = new Card(10, cardGame.Suit.CLUB);

        [TestMethod]
        public void TestGetnumber()
        {
            Assert.AreEqual(1, cardH1.Getnumber());
            Assert.AreEqual(1, cardD1.Getnumber());
            Assert.AreEqual(1, cardS1.Getnumber());
            Assert.AreEqual(1, cardC1.Getnumber());

            Assert.AreEqual(10, cardH10.Getnumber());
            Assert.AreEqual(10, cardD10.Getnumber());
            Assert.AreEqual(10, cardS10.Getnumber());
            Assert.AreEqual(10, cardC10.Getnumber());

            Assert.AreNotEqual(12, cardH1.Getnumber());
            Assert.AreNotEqual(13, cardD1.Getnumber());
            Assert.AreNotEqual(14, cardS1.Getnumber());
            Assert.AreNotEqual(15, cardC1.Getnumber());

            Assert.AreNotEqual(1, cardH10.Getnumber());
            Assert.AreNotEqual(2, cardD10.Getnumber());
            Assert.AreNotEqual(3, cardS10.Getnumber());
            Assert.AreNotEqual(4, cardC10.Getnumber());
        }

        [TestMethod]
        public void TestGetSuit()
        {
            Assert.AreEqual(Suit.HEART, cardH1.GetSuit());
            Assert.AreEqual(Suit.DIAMOND, cardD1.GetSuit());
            Assert.AreEqual(Suit.SPADE, cardS1.GetSuit());
            Assert.AreEqual(Suit.CLUB, cardC1.GetSuit());

            Assert.AreEqual(Suit.HEART, cardH1.GetSuit());
            Assert.AreEqual(Suit.DIAMOND, cardD1.GetSuit());
            Assert.AreEqual(Suit.SPADE, cardS1.GetSuit());
            Assert.AreEqual(Suit.CLUB, cardC1.GetSuit());

            Assert.AreNotEqual(Suit.HEART, cardC1.GetSuit());
            Assert.AreNotEqual(Suit.DIAMOND, cardS1.GetSuit());
            Assert.AreNotEqual(Suit.SPADE, cardD1.GetSuit());
            Assert.AreNotEqual(Suit.CLUB, cardH1.GetSuit());

            Assert.AreNotEqual(Suit.HEART, cardC1.GetSuit());
            Assert.AreNotEqual(Suit.DIAMOND, cardS1.GetSuit());
            Assert.AreNotEqual(Suit.SPADE, cardD1.GetSuit());
            Assert.AreNotEqual(Suit.CLUB, cardH1.GetSuit());
        }

        [TestMethod]
        public void TestGetCardString()
        {
            Assert.AreEqual("As of heart", cardH1.GetCardString());
            Assert.AreEqual("As of spade", cardS1.GetCardString());
            Assert.AreEqual("As of diamond", cardD1.GetCardString());
            Assert.AreEqual("As of club", cardC1.GetCardString());

            Assert.AreEqual("Ten of heart", cardH10.GetCardString());
            Assert.AreEqual("Ten of spade", cardS10.GetCardString());
            Assert.AreEqual("Ten of diamond", cardD10.GetCardString());
            Assert.AreEqual("Ten of club", cardC10.GetCardString());

            Assert.AreNotEqual("As of hddddddeart", cardH1.GetCardString());
            Assert.AreNotEqual("As of spadffffffffe", cardS1.GetCardString());
            Assert.AreNotEqual("As of diamonddddd", cardD1.GetCardString());
            Assert.AreNotEqual("As of clubfffffff", cardC1.GetCardString());

            Assert.AreNotEqual("As of hzefzef", cardH10.GetCardString());
            Assert.AreNotEqual("As of spadgsdgsdge", cardS10.GetCardString());
            Assert.AreNotEqual("As of diamqrgerg", cardD10.GetCardString());
            Assert.AreNotEqual("As of clsfsdgsdgb", cardC10.GetCardString());
        }
    }
}
<file_sep>/DotNet_epicture_2017/epicture/epictureTest/ImgurTest.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using epicture;

namespace epictureTest
{
    [TestClass]
    public class ImgurTest
    {
        private Imgur_client imgur { get; set; }

        [TestInitialize]
        public void Initializer()
        {
            this.imgur = new Imgur_client();
        }

        [TestMethod]
        public void client_info()
        { 
            string id = "4c87c24c218e973";
            string sct = "93e8a179129b8393c0256c60a57a0abd40da4b6b";

            Assert.AreEqual(this.imgur.app_id, id);
            Assert.AreEqual(this.imgur.secret, sct);
        }

        [TestMethod]
        public void username()
        {
            string name = null;

            Assert.AreEqual(this.imgur.account_username, name);
        }

        [TestMethod]
        public void testHttpGet()
        {
            string x = "false";
             Task.Run(async () =>
            {
                string str = await this.imgur.HttpGet("blabla");
                Assert.AreNotEqual(str, x);
            });
        }

        [TestMethod]
        public void testHttpDelete()
        {
            string x = "false";
            Task.Run(async () =>
            {
                string str = await this.imgur.HttpGet("sfsdmlfksdmlfksdfksml");
                Assert.AreNotEqual(str, x);
            });
        }

    }
}
<file_sep>/DOT_AREA_2017/DOT_AREA_2017/DOT_AREA_2017/Home/Login.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;

namespace DOT_AREA_2017
{
    public partial class Login : Page
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

        protected void Page_Load(object sender, EventArgs e)
        {
            con.Open();
        }

        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if ((TextLogin.Text != "" && TextLogin != null)
                    && (TextPass.Text != "" && TextPass.Text != null))
                {
                    string sql = "select * from [User] where Login=@login AND Password=@<PASSWORD>";
                    SqlCommand cmd = new SqlCommand(sql, con);
                    cmd.Parameters.AddWithValue("@login", TextLogin.Text);
                    cmd.Parameters.AddWithValue("@password", TextPass.Text);

                    
                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {
                        var url = String.Format("~/Home/Logged.aspx?login={0}&email={1}&username={2}", reader["Login"], reader["Email"], reader["UserName"]);
                        Response.Redirect(url);
                    }
                    else
                    {
                        Label1.ForeColor = System.Drawing.Color.Red;
                        Label1.Visible = true;
                        Label1.Text = "Invalid login or password ...";
                    }
                    reader.Close();
                    con.Close();
                }
                else
                {
                    Label1.ForeColor = System.Drawing.Color.Red;
                    Label1.Visible = true;
                    Label1.Text = "Invalid login or password ...";
                }
            }
            catch (SqlException ex)
            {
                Label1.ForeColor = System.Drawing.Color.Red;
                Label1.Visible = true;
                Label1.Text = ex.Message;
            }
        }
    }
}<file_sep>/DotNet_todolist_2017/todolist/EditTask.xaml.cs
﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// Pour plus d'informations sur le modèle d'élément Page vierge, consultez la page https://go.microsoft.com/fwlink/?LinkId=234238

namespace todolist
{
    /// <summary>
    /// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
    /// </summary>
    public sealed partial class EditTask : Page
    {
        public EditTask()
        {
            this.InitializeComponent();
            App db = App.Current as App;
            Title.Text = db.CurrentObj.Title;
            ContentContent.Text = db.CurrentObj.Content;
            Date.Date = db.CurrentObj.DateT.Date;
        }

        private async void DeleteTodo_OnClick(object sender, RoutedEventArgs e)
        {
            string title = "Deleting task";
            string content = "Do you want to delete this task ?";
            UICommand yesCommand = new UICommand("Yes");
            UICommand noCommand = new UICommand("No");

            var dialog = new MessageDialog(content, title);
            dialog.Options = MessageDialogOptions.None;
            dialog.Commands.Add(yesCommand);
            dialog.Commands.Add(noCommand);
            dialog.DefaultCommandIndex = 0;
            dialog.CancelCommandIndex = 0;

            IUICommand command = await dialog.ShowAsync();

            if (command != noCommand)
            {
                var db = App.Current as App;
                db.connection.Query<TodoDB>("DELETE FROM TodoDB WHERE Id =" + db.CurrentObj.Id);
                Frame.Navigate(typeof(MainPage));
            }
        }

        private void BackToMain_OnClick(object sender, RoutedEventArgs e)
        {
            Frame.Navigate(typeof(MainPage));
        }

        private void Valid_Click(object sender, RoutedEventArgs e)
        {
            if (Title.Text.Length == 0)
            {
                Error.Text = "You must set a title for the task";
                Error.Visibility = Visibility.Visible;
                return;
            }
            else if (ContentContent.Text.Length == 0)
            {
                Error.Text = "You must set a content for the task";
                Error.Visibility = Visibility.Visible;
                return;
            }
            else if (!Date.Date.HasValue)
            {
                Error.Text = "You must choose a date for the task";
                Error.Visibility = Visibility.Visible;
                return;
            }
            else
            {
                App db = App.Current as App;

                db.CurrentObj.Title = Title.Text;
                db.CurrentObj.DateT = Date.Date.Value;
                db.CurrentObj.Content = ContentContent.Text;

                db.connection.Update(db.CurrentObj);

                Frame.Navigate(typeof(MainPage));
            }


        }

        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            string title = "Do you want delete this task ?";
            UICommand delete = new UICommand("Delete");
            UICommand cancel = new UICommand("Cancel");

            MessageDialog option = new MessageDialog(title);
            option.Commands.Add(delete);
            option.Commands.Add(cancel);
            IUICommand command = await option.ShowAsync();

            if (command != cancel)
            {
                App db = App.Current as App;
                db.connection.Query<TodoDB>("DELETE FROM TodoDB WHERE Id =" + db.CurrentObj.Id);
            }
            Frame.Navigate(typeof(MainPage));
        }

        private void Back_OnClick(object sender, RoutedEventArgs e)
        {
            Frame.Navigate(typeof(MainPage));
        }
    }
}
<file_sep>/DOT_cardGames_2017/cardGame/cardGame/Program.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using DotNetty.Codecs;
using DotNetty.Handlers.Logging;
using DotNetty.Handlers.Tls;
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Sockets;
using Newtonsoft.Json;

namespace cardGame
{
    public class ProtocolJson
    {
        public string message { get; set; }
        public DateTime messageDate { get; set; }
    }
    class Program
    {
        static async Task RunServerAsync()
        {
            var bossGroup = new MultithreadEventLoopGroup(1);
            var workerGroup = new MultithreadEventLoopGroup();

            var STRING_ENCODER = new StringEncoder();
            var STRING_DECODER = new StringDecoder();
            var SERVER_HANDLER = new ChatServerHandler();

            try
            {
                var bootstrap = new ServerBootstrap();
                bootstrap
                    .Group(bossGroup, workerGroup)
                    .Channel<TcpServerSocketChannel>()
                    .Option(ChannelOption.SoBacklog, 100)
                    .Handler(new LoggingHandler(LogLevel.INFO))
                    .ChildHandler(new ActionChannelInitializer<ISocketChannel>(channel =>
                    {
                        IChannelPipeline pipeline = channel.Pipeline;
                        pipeline.AddLast(new DelimiterBasedFrameDecoder(8192, Delimiters.LineDelimiter()));
                        pipeline.AddLast(STRING_ENCODER, STRING_DECODER, SERVER_HANDLER);
                    }));

                IChannel bootstrapChannel = await bootstrap.BindAsync(8080);

                Console.ReadLine();

                await bootstrapChannel.CloseAsync();
            }
            finally
            {
                Task.WaitAll(bossGroup.ShutdownGracefullyAsync(), workerGroup.ShutdownGracefullyAsync());
            }
        }

        static void Main() => RunServerAsync().Wait();
    }
}
<file_sep>/DotNet_epicture_2017/epicture/epictureTest/FlickrTest.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using epicture;

namespace epictureTest
{
    [TestClass]
    public class FlickrTest
    {
        [TestMethod]
        public void Auth()
        {

        }
    }
}
<file_sep>/DOT_cardGames_2017/cardGame/cardGame/Blackjack.cs
using DotNetty.Transport.Channels;
using System;
using System.Collections.Generic;

namespace cardGame
{
    public class Blackjack
    {
        private List<Player> _players;
        private int _numberOfPlayer;
        private GameState _state;
        private Player _playerTurn;
        private Dealer _dealer;
        private int _numberOfDeck;

        public Blackjack()
        {
            _players = new List<Player>();
            _numberOfPlayer = 0;
            _state = GameState.LOBBY;
            _playerTurn = null;
            _dealer = null;
            _numberOfDeck = 1;
        }

        public Card Card
        {
            get => default(Card);
            set
            {
            }
        }

        internal GameState GameState
        {
            get => default(GameState);
            set
            {
            }
        }

        public Dealer Dealer
        {
            get => default(Dealer);
            set
            {
            }
        }

        public Blackjack Blackjack1
        {
            get => default(Blackjack);
            set
            {
            }
        }

        public Player Player
        {
            get => default(Player);
            set
            {
            }
        }

        private void CommandShowLobby(Player player)
        {
            foreach (var p in _players)
                player.Write(p.GetName());
        }

        //handle command that can be use at anytime
        private bool GeneralCommand(Player player, string cmd)
        {
            if (string.Equals("showlobby", cmd, StringComparison.OrdinalIgnoreCase))
                CommandShowLobby(player);
            else
                return false;
            return true;
        }

        //Start a new turn of blackjack    
        private void HandOutTwoCardToAll()
        {
            _dealer.ClearHand();
            foreach (var p in _players)
                p.ClearHand();
            _dealer.DealCard(null);
            foreach (var p in _players)
                _dealer.DealCard(p);
            _dealer.DealCard(null);
            foreach (var p in _players)
                _dealer.DealCard(p);
        }

        //print cards to all player
        private void DisplayTurnStateToAllPlayer()
        {
            foreach (var p in _players)
                _dealer.DisplayHideHandToPlayer(p);
            foreach (var p in _players)
                p.DisplayHand();
        }

        //print "it is player's turn"
        public void DisplayPlayerTurnToAll()
        {
            foreach (var p in _players)
            {
                if (p != _playerTurn)
                    p.Write("It is " + _playerTurn.GetName() + "'s turn");
            }
        }



        //Start a new turn of black from "start" command
        private void InitiateNewGame(Player player)
        {
            _dealer = new Dealer(_numberOfDeck);
            _playerTurn = player;
            HandOutTwoCardToAll();
            DisplayTurnStateToAllPlayer();
            DisplayPlayerTurnToAll();
            _playerTurn.AskPlayerAction();
        }

        private void CommandStart(Player player)
        {
            _state = GameState.GAME;
            _playerTurn = player;
            InitiateNewGame(player);
        }

        private void CommandDeck(Player player, string cmd)
        {
            int number = 1;

            if (Int32.TryParse(cmd, out number) == false)
                player.InvalidCommand();
            else if (number < 1 || number > 4)
                player.Write("You can play with 1 to 4 deck only");
            else
            {
                _numberOfDeck = number;
                player.Write("Number of deck set to " + _numberOfDeck);
            }

        }

        //handle command from lobby
        private void LobbyCommand(Player player, string cmd)
        {
            if (string.Equals("start", cmd, StringComparison.OrdinalIgnoreCase))
                CommandStart(player);
            else if (cmd.ToLower().StartsWith("deck ") == true)
                CommandDeck(player, cmd.Substring(5));
            else
                player.InvalidCommand();
        }

        private int GetPlayerByIndex(Player player)
        {
            int i = 0;

            for (i = 0; i < _players.Count; i++)
                if (_players[i] == player)
                    break;
            return i;
        }

        private void SetNextPlayerturn()
        {
            int index = GetPlayerByIndex(_playerTurn);
            int max = _players.Count;
            Player next;

            if (index >= max - 1)
                next = _players[0];
            else
                next = _players[index + 1];
            _playerTurn = next;
            if (_playerTurn.IsHandEmpty() == true && _players.Count > 1)
            {
                SetNextPlayerturn();
            }

        }

        private bool IsEndTurn()
        {
            foreach (var p in _players)
                if (p.GetHasPlay() == false && p.IsHandEmpty() == false)
                    return false;
            return true;
        }

        private void StartNewTurn()
        {
            foreach (var p in _players)
            {
                p.SetHasPlay(false);
                p.Write("Starting new turn !");
            }
            if (_dealer.GetShoeCount() < 15)
            {
                _dealer.ClearShoe();
                _dealer.GenerateShoe();
            }
            HandOutTwoCardToAll();
            DisplayTurnStateToAllPlayer();
            DisplayPlayerTurnToAll();
            _playerTurn.AskPlayerAction();
        }

        private void CalculateWinners()
        {
            if (_dealer.IsBusted())
            {
                foreach (var p in _players)
                {
                    if (p.IsHandEmpty() == false)
                    {
                        if (p.IsBusted())
                            p.Write("You lost this hand");
                        else
                            p.Write("You won this hand !");
                    }
                }
            }
            else
            {
                foreach (var p in _players)
                {
                    if (p.IsHandEmpty() == false)
                    {
                        if (p.IsBusted() || p.GetHandValue() < _dealer.GetHandValue())
                            p.Write("You lost this hand");
                        else if (p.GetHandValue() == _dealer.GetHandValue())
                            p.Write("Draw");
                        else
                            p.Write("You won this hand !");
                    }
                }
            }
        }

        private void DealerTurn()
        {
            foreach (var p in _players)
            {
                if (p.IsHandEmpty() == false)
                {
                    p.Write("Dealer's turn");
                    _dealer.DisplayHandToPlayer(p, true);
                }
            }
            while (_dealer.GetHandValue() < 17)
            {
                _dealer.DealCard(null);
                foreach (var p in _players)
                {
                    if (p.IsHandEmpty() == false)
                        _dealer.DisplayHandToPlayer(p, true);
                }
            }
        }

        private void CommandHit(Player player)
        {
            _dealer.DealCard(player);
            player.DisplayHand();
            if (player.IsBusted() == true)
            {
                player.Write("Busted !");
                player.SetHasPlay(true);
                SetNextPlayerturn();
                if (IsEndTurn() == true)
                {
                    DealerTurn();
                    CalculateWinners();
                    StartNewTurn();
                }
                else
                {
                    DisplayPlayerTurnToAll();
                    _playerTurn.AskPlayerAction();
                }
            }
            else
                _playerTurn.AskPlayerAction();
        }

        private void CommandStand(Player player)
        {
            player.SetHasPlay(true);
            SetNextPlayerturn();
            if (IsEndTurn() == true)
            {
                DealerTurn();
                CalculateWinners();
                StartNewTurn();
            }
            else
            {
                DisplayPlayerTurnToAll();
                _playerTurn.AskPlayerAction();
            }
        }

        private void CommandDouble(Player player)
        {
            _dealer.DealCard(player);
            player.DisplayHand();
            player.SetHasPlay(true);
            SetNextPlayerturn();
            if (player.IsBusted() == true)
                player.Write("Busted !");
            if (IsEndTurn() == true)
            {
                DealerTurn();
                CalculateWinners();
                StartNewTurn();
            }
            else
            {
                DisplayPlayerTurnToAll();
                _playerTurn.AskPlayerAction();
            }
        }

        //handle command related to ingame blackjack
        private void GameCommand(Player player, string cmd)
        {
            if (player != _playerTurn)
                player.InvalidCommand();
            else if (string.Equals("hit", cmd, StringComparison.OrdinalIgnoreCase))
                CommandHit(player);
            else if (string.Equals("stand", cmd, StringComparison.OrdinalIgnoreCase))
                CommandStand(player);
            else if (string.Equals("double", cmd, StringComparison.OrdinalIgnoreCase))
                CommandDouble(player);
            else
                player.InvalidCommand();
        }

        //handle command related to blackjack
        private void BlackjackCommand(Player player, string cmd)
        {
            if (_state == GameState.LOBBY)
                LobbyCommand(player, cmd);
            else if (_state == GameState.GAME)
                GameCommand(player, cmd);
        }

        // main function
        public void BlackjackHandler(IChannelHandlerContext contex, string cmd)
        {
            Player player = GetPlayerByContex(contex);

            if (GeneralCommand(player, cmd) == false)
                BlackjackCommand(player, cmd);
        }

        public void AddPlayer(IChannelHandlerContext contex)
        {
            string name = "Player " + _numberOfPlayer++;
            Player player = new Player(contex, name);
            
            foreach (var p in _players)
            {
                if (p != player)
                    p.Write(player.GetName() + " has join");
            }
            _players.Add(player);
            if (_state == GameState.GAME)
            {
                player.Write("Wait for next turn");
                _playerTurn.AskPlayerAction();
            }
        }

        public Player GetPlayerByContex(IChannelHandlerContext contex)
        {
            Player player = null;

            foreach (var p in _players)
            {
                if (p.GetContex() == contex)
                {
                    player = p;
                    break;
                }
            }
            return player;
        }

        public void RemovePlayerByContex(IChannelHandlerContext contex)
        {
            Player player = GetPlayerByContex(contex);

            foreach (var p in _players)
            {
                if (player != p)
                    p.Write(player.GetName() + " has left");
            }
            _players.Remove(player);
            if (_players.Count == 0)
                _state = GameState.LOBBY;
            if (_state == GameState.GAME)
            {
                SetNextPlayerturn();
                if (IsEndTurn() == true)
                {
                    DealerTurn();
                    CalculateWinners();
                    StartNewTurn();
                }
                else
                {
                    DisplayPlayerTurnToAll();
                    _playerTurn.AskPlayerAction();
                }
            }
        }
    }
}<file_sep>/DOT_cardGames_2017/cardGame/client/Program.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using DotNetty.Codecs;
using DotNetty.Handlers.Logging;
using DotNetty.Handlers.Tls;
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Sockets;
using Newtonsoft.Json;

namespace client
{
    public class ProtocolJson
    {
        public string message { get; set; }
        public DateTime messageDate { get; set; }
    }
    class Program
    {
        static async Task RunClientAsync()
        {
            var HOST = IPAddress.Parse("127.0.0.1");
            var group = new MultithreadEventLoopGroup();
            try
            {
                var bootstrap = new Bootstrap();
                bootstrap
                    .Group(group)
                    .Channel<TcpSocketChannel>()
                    .Option(ChannelOption.TcpNodelay, true)
                    .Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
                    {
                        IChannelPipeline pipeline = channel.Pipeline;
                        pipeline.AddLast(new DelimiterBasedFrameDecoder(8192, Delimiters.LineDelimiter()));
                        pipeline.AddLast(new StringEncoder(), new StringDecoder(), new ChatClientHandler());
                    }));

                IChannel bootstrapChannel = await bootstrap.ConnectAsync(new IPEndPoint(HOST, 8080));

                ProtocolJson pj = new ProtocolJson();

                for (;;)
                {
                    string line = Console.ReadLine();

                    pj.message = line;
                    pj.messageDate = DateTime.Now;
                    string Json = JsonConvert.SerializeObject(pj, Formatting.None);

                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }
                    try
                    {
                        await bootstrapChannel.WriteAndFlushAsync(Json + "\r\n");
                        //await bootstrapChannel.WriteAndFlushAsync(line + "\r\n");
                    }
                    catch
                    {
                    }
                    if (string.Equals(line, "bye", StringComparison.OrdinalIgnoreCase))
                    {
                        await bootstrapChannel.CloseAsync();
                        break;
                    }
                }

                await bootstrapChannel.CloseAsync();
            }
            finally
            {
                group.ShutdownGracefullyAsync().Wait(1000);
            }
        }

        static void Main() => RunClientAsync().Wait();
    }
}
<file_sep>/DOT_AREA_2017/DOT_AREA_2017/DOT_AREA_2017/Home/Logged.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DOT_AREA_2017
{
    public partial class Logged : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var login = Request["login"];
            var email = Request["email"];
            var username = Request["username"];

            LabelUsername.Visible = true;
            LabelUsername.Text = String.Format("Welcome {0}", login);
        }
    }
}<file_sep>/DOT_cardGames_2017/cardGame/client/ChatClientHandler.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DotNetty.Transport.Channels;
using Newtonsoft.Json;

namespace client
{
    public class ChatClientHandler : SimpleChannelInboundHandler<string>
    {
        internal Program Program
        {
            get => default(Program);
            set
            {
            }
        }

        protected override void ChannelRead0(IChannelHandlerContext contex, string msg)
        {
            Console.WriteLine(msg);
        }
        public override void ExceptionCaught(IChannelHandlerContext contex, Exception e)
        {
            Console.WriteLine(DateTime.Now.Millisecond);
            Console.WriteLine(e.StackTrace);
            contex.CloseAsync();
        }
    }
}
<file_sep>/DOT_AREA_2017/DOT_AREA_2017/DOT_AREA_2017/Home/API/Facebook.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mailinblue;
using Vianett.Common.Log4net;
using System.Net;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using Facebook;

namespace DOT_AREA_2017
{
    public partial class Facebook : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonMail_Click(object sender, EventArgs e)
        {
            string message = TextFacebook.InnerText;
            ///////////////////////////////////////////////// SEND IN BLUE //////////////////////////////////////////////////
            API sendinBlue = new mailinblue.API("ERWXqjT4mS3aA05V", 5000);    //Optional parameter: Timeout in MS
            Dictionary<string, Object> data = new Dictionary<string, Object>();
            Dictionary<string, string> to = new Dictionary<string, string>();
            to.Add(TextDestination.Text, "to whom!");
            List<string> from_name = new List<string>();
            from_name.Add("<EMAIL>");
            from_name.Add("AREA.NET");
            //List<string> attachment = new List<string>();
            //attachment.Add("https://domain.com/path-to-file/filename1.pdf");
            //attachment.Add("https://domain.com/path-to-file/filename2.jpg");

            data.Add("to", to);
            data.Add("from", from_name);
            data.Add("subject", "AREA send in blue");
            data.Add("html", String.Concat("You post the following message on Facebook : ", message));
            //data.Add("attachment", attachment);

            Object sendEmail = sendinBlue.send_email(data);
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            string accessToken = "<KEY>";
            var objFacebookClient = new FacebookClient(accessToken);
            var parameters = new Dictionary<string, object>();
            parameters["message"] = message;
            try
            {
                objFacebookClient.Post("feed", parameters);
                LabelResult.ForeColor = System.Drawing.Color.Green;
                LabelResult.Visible = true;
                LabelResult.Text = "Message posted on Facebook and sended to " + TextDestination.Text + " !";
            }
            catch (FacebookApiException fbex)
            {
                LabelResult.Visible = true;
                LabelResult.Text = fbex.Message;
            }
        }

        protected void ButtonPhone_Click(object sender, EventArgs e)
        {
            string message = TextFacebook.InnerText;
            string accessToken = "<KEY>";
            var objFacebookClient = new FacebookClient(accessToken);
            var parameters = new Dictionary<string, object>();
            parameters["message"] = message;

            //////////////////////////////////////////// VIANETT /////////////////////////////////////////
            string username = "<EMAIL>";
            string password = "<PASSWORD>";
            string msgsender = "33683821203";
            string destinationaddr = string.Concat("33", TextDestination.Text.Remove(0, 1).ToString());

            ViaNettSMS s = new ViaNettSMS(username, password);
            ViaNettSMS.Result result;
            try
            {
                objFacebookClient.Post("feed", parameters);
                result = s.sendSMS(msgsender, destinationaddr, String.Concat("You post on Facebook : ", message));
                LabelResult.ForeColor = System.Drawing.Color.Green;
                LabelResult.Visible = true;
                LabelResult.Text = "Message posted on Facebook and sended to " + TextDestination.Text + " !";
            }
            catch (FacebookApiException fbex)
            {
                LabelResult.Visible = true;
                LabelResult.Text = fbex.Message;
            }
        }

        protected void ButtonFb_Click(object sender, EventArgs e)
        {
            string message = TextFacebook.InnerText;
            //The facebook json url to update the status
            string twitterURL = "https://api.twitter.com/1.1/statuses/update.json";

            //set the access tokens (REQUIRED)
            string oauth_consumer_key = "OJiBjYwsTTPUHpgIpGbdDfoZZ";
            string oauth_consumer_secret = "<KEY>";
            string oauth_token = "<KEY>";
            string oauth_token_secret = "<KEY>";

            // set the oauth version and signature method
            string oauth_version = "1.0";
            string oauth_signature_method = "HMAC-SHA1";

            // create unique request details
            string oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
            System.TimeSpan timeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
            string oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();

            // create oauth signature
            string baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" + "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&status={6}";

            string baseString = string.Format(
                baseFormat,
                oauth_consumer_key,
                oauth_nonce,
                oauth_signature_method,
                oauth_timestamp, oauth_token,
                oauth_version,
                Uri.EscapeDataString(message)
            );

            string oauth_signature = null;
            using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(Uri.EscapeDataString(oauth_consumer_secret) + "&" + Uri.EscapeDataString(oauth_token_secret))))
            {
                oauth_signature = Convert.ToBase64String(hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes("POST&" + Uri.EscapeDataString(twitterURL) + "&" + Uri.EscapeDataString(baseString))));
            }

            // create the request header
            string authorizationFormat = "OAuth oauth_consumer_key=\"{0}\", oauth_nonce=\"{1}\", " + "oauth_signature=\"{2}\", oauth_signature_method=\"{3}\", " + "oauth_timestamp=\"{4}\", oauth_token=\"{5}\", " + "oauth_version=\"{6}\"";

            string authorizationHeader = string.Format(
                authorizationFormat,
                Uri.EscapeDataString(oauth_consumer_key),
                Uri.EscapeDataString(oauth_nonce),
                Uri.EscapeDataString(oauth_signature),
                Uri.EscapeDataString(oauth_signature_method),
                Uri.EscapeDataString(oauth_timestamp),
                Uri.EscapeDataString(oauth_token),
                Uri.EscapeDataString(oauth_version)
            );

            HttpWebRequest objHttpWebRequest = (HttpWebRequest)WebRequest.Create(twitterURL);
            objHttpWebRequest.Headers.Add("Authorization", authorizationHeader);
            objHttpWebRequest.Method = "POST";
            objHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
            using (Stream objStream = objHttpWebRequest.GetRequestStream())
            {
                byte[] content = ASCIIEncoding.ASCII.GetBytes("status=" + Uri.EscapeDataString(message));
                objStream.Write(content, 0, content.Length);
            }

            var responseResult = "";
            ///////////////////////////////////////////////// FACEBOOK //////////////////////////////////////////////////
            string accessToken = "<KEY>";
            var objFacebookClient = new FacebookClient(accessToken);
            var parameters = new Dictionary<string, object>();
            parameters["message"] = message;
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            try
            {
                objFacebookClient.Post("feed", parameters);
                //success posting
                WebResponse objWebResponse = objHttpWebRequest.GetResponse();
                StreamReader objStreamReader = new StreamReader(objWebResponse.GetResponseStream());
                responseResult = objStreamReader.ReadToEnd().ToString();
            }
            catch (FacebookApiException fbex)
            {
                LabelResult.Visible = true;
                LabelResult.Text = fbex.Message;
            }
            catch (Exception ex)
            {
                //throw exception error
                responseResult = "Twitter Post Error: " + ex.Message.ToString() + ", authHeader: " + authorizationHeader;
            }
        }
    }
}<file_sep>/DOT_cardGames_2017/cardGame/cardGameTests/BlackjackTests.cs
﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using cardGame;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cardGame.Tests
{
    [TestClass()]
    public class BlackjackTests
    {
        Blackjack bj = new Blackjack();

        [TestMethod()]
        public void GetPlayerByIndexTest()
        {
        }
    }
}<file_sep>/DOT_cardGames_2017/cardGame/cardGame/Card.cs
using System.Collections.Generic;

namespace cardGame
{ 
    public class Card
    {
        private int _number;
        private int _value;
        private Suit _suit;
        private Dictionary<int, string> _dico;

        public Card(int number, Suit suit)
        {
            _number = number;
            _suit = suit;
            _value = (number > 10 ? 10 : number);
            _dico = new Dictionary<int, string>()
            {
                { 1, "As"},
                { 2, "Two"},
                { 3, "Three"},
                { 4, "Four"},
                { 5, "Five"},
                { 6, "Six"},
                { 7, "Seven"},
                { 8, "Eight"},
                { 9, "Nine"},
                { 10, "Ten"},
                { 11, "Jack"},
                { 12, "Queen"},
                { 13, "King"},
            };
        }

        public Suit Suit
        {
            get => default(Suit);
            set
            {
            }
        }

        public int Getnumber()
        {
            return _number;
        }

        public int GetValue()
        {
            return _value;
        }

        public Suit GetSuit()
        {
            return _suit;
        }

        public string GetCardString()
        {
            string str = "";

            str += _dico[_number] + " of " + _suit.ToString().ToLower();
            return str;
        }
    }
}<file_sep>/DotNet_epicture_2017/epicture/epictureTest/UnitTest.cs
﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using epicture;

namespace epictureTest
{
    [TestClass]
    public class UnitTest1
    {
    }
}
<file_sep>/DOT_cardGames_2017/cardGame/cardGame/Dealer.cs
using System;
using System.Collections.Generic;
using System.Security.Cryptography;

namespace cardGame
{
    public class Dealer
    {
        private List<Card> _shoe = new List<Card>();
        private Hand _hand = new Hand();
        private int _numberOfDeck;

        public Dealer(int numberOfDeck)
        {
            _numberOfDeck = numberOfDeck;
            GenerateShoe();
        }

        public Card Card
        {
            get => default(Card);
            set
            {
            }
        }

        public void ClearShoe() => _shoe.Clear();

        //Create a new shoe from "_numberOfDeck"
        public void GenerateShoe()
        {
            for (int count = 0; count < _numberOfDeck; count++)
            {
                for (int i = 1; i <= 13; i++)
                    _shoe.Add(new Card(i, Suit.HEART));
                for (int i = 1; i <= 13; i++)
                    _shoe.Add(new Card(i, Suit.SPADE));
                for (int i = 1; i <= 13; i++)
                    _shoe.Add(new Card(i, Suit.DIAMOND));
                for (int i = 1; i <= 13; i++)
                    _shoe.Add(new Card(i, Suit.CLUB));
            }
            Shuffle();
        }

        public void Shuffle()
        {
            RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider();
            int n = _shoe.Count;

            while (n > 1)
            {
                byte[] box = new byte[1];
                do provider.GetBytes(box);
                while (!(box[0] < n * (Byte.MaxValue / n)));
                int k = (box[0] % n);
                n--;
                Card card = _shoe[k];
                _shoe[k] = _shoe[n];
                _shoe[n] = card;
            }
        }

        public void DealCard(Player player, int index = 0)
        {
            Card card = _shoe[0];

            _shoe.RemoveAt(0);
            if (player == null)
            {
                TakeCard(card);
            }
            else
            {
                player.TakeCard(card, index);
            }
        }

        public int GetShoeCount() => _shoe.Count;

        public void TakeCard(Card card) => _hand.TakeCard(card);

        public void ClearHand(int index = 0)
        {
            _hand.ClearHand(index);
        }

        public int GetHandValue(int index = 0) => _hand.GetHandValue(index);

        public void DisplayHandToPlayer(Player player, bool dealer = false) => player.Write(_hand.GetDisplayHandMsg(0, dealer));

        public void DisplayHideHandToPlayer(Player player) => player.Write(_hand.GetDisplayHidHandMsg());

        public bool IsBusted() => _hand.IsBusted();
    }
}<file_sep>/DOT_AREA_2017/DOT_AREA_2017/DOT_AREA_2017/Home/Others/TwitterPerso.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DOT_AREA_2017.Home.Others
{
    public class TwitterPerso
    {
        private string oauth_consumer_key = "Cq9CVm4dCDhD3hZASE37ddWP1";
        private string oauth_consumer_secret = "<KEY>";
        private string oauth_token = "<KEY>";
        private string oauth_token_secret = "<KEY>";

        public TwitterPerso()
        {

        }

        public string getConsumerKey()
        {
            return (this.oauth_consumer_key);
        }

        public string getConsumerSecret()
        {
            return (this.oauth_consumer_secret);
        }

        public string getToken()
        {
            return (this.oauth_token);
        }

        public string getTokenSecret()
        {
            return (this.oauth_token_secret);
        }

    }
}<file_sep>/DotNet_todolist_2017/todolist/AddTask.xaml.cs
﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// Pour plus d'informations sur le modèle d'élément Page vierge, consultez la page https://go.microsoft.com/fwlink/?LinkId=234238

namespace todolist
{
    /// <summary>
    /// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
    /// </summary>
    public sealed partial class AddTask : Page
    {
        public AddTask()
        {
            this.InitializeComponent();
        }

        /*
        private void Back_OnClick(object sender, RoutedEventArgs e)
        {
            Frame.Navigate(typeof(MainPage));
        }
        */

        private void Valid_Click(object sender, RoutedEventArgs e)
        {
            App db = App.Current as App;

            if (TitleContent.Text.Length == 0)
            {
                parseCheck.Text = "You must set a title for the task";
                parseCheck.Visibility = Visibility.Visible;
                return;
            }
            else if (ContentContent.Text.Length == 0)
            {
                parseCheck.Text = "You must set a content for the task.";
                parseCheck.Visibility = Visibility.Visible;
                return;
            }
            else if (!DueDate.Date.HasValue)
            {
                parseCheck.Text = "You must choose a date for the task.";
                parseCheck.Visibility = Visibility.Visible;
                return;
            }
            else
            {
                db.connection.Insert(new TodoDB()
                {
                    Title = TitleContent.Text,
                    DateT = DueDate.Date.Value,
                    Content = ContentContent.Text,
                    Status = !true,
                });

                Frame.Navigate(typeof(MainPage));
            }
        }

        private void Return_OnClick(object sender, RoutedEventArgs e)
        {
            Frame.Navigate(typeof(MainPage));
        }
    }
}
<file_sep>/DOT_AREA_2017/DOT_AREA_2017/DOT_AREA_2017/Home/Register.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace DOT_AREA_2017
{
    public partial class Register : Page
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        protected void Page_Load(object sender, EventArgs e)
        {
            con.Open();
        }

        protected void ButtonRegister_Click(object sender, EventArgs e)
        {
            try
            {
                if (TextLogin.Text != "" && TextLogin != null)
                {
                    string sql = "insert into [User] (Login,Password,Email,UserName) VALUES(@login,@password,@email,@username)";
                    SqlCommand cmd = new SqlCommand(sql, con);
                    cmd.Parameters.AddWithValue("@login", TextLogin.Text);
                    cmd.Parameters.AddWithValue("@password", <PASSWORD>);
                    cmd.Parameters.AddWithValue("@email", TextEmail.Text);
                    cmd.Parameters.AddWithValue("@username", TextUser.Text);
                    cmd.ExecuteNonQuery();

                    con.Close();
                    Label1.Visible = true;
                    Label1.Text = "Registration successful !";

                    TextLogin.Text = "";
                    TextPass.Text = "";
                    TextEmail.Text = "";
                    TextUser.Text = "";
                }
                else
                {
                    Label1.ForeColor = System.Drawing.Color.Red;
                    Label1.Visible = true;
                    Label1.Text = "ERROR FORM";
                }
            }
            catch (SqlException ex)
            {
                Label1.ForeColor = System.Drawing.Color.Red;
                Label1.Visible = true;
                Label1.Text = ex.Message.ToString();

            }
        }

        protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {

        }
    }
}<file_sep>/DotNet_todolist_2017/todolist/MainPage.xaml.cs
﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Popups;
using Windows.UI.Text;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using SQLite.Net.Attributes;

// Pour plus d'informations sur le modèle d'élément Page vierge, consultez la page https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace todolist
{
    public class Task : Grid
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public DateTimeOffset DateT { get; set; }
        public string Content { get; set; }
        public bool Status { get; set; }
    }

    public class TodoDB
    {
        [PrimaryKey, AutoIncrement]

        public int Id { get; set; }
        public string Title { get; set; }
        public DateTimeOffset DateT { get; set; }
        public string Content { get; set; }
        public bool Status { get; set; }
    }

    /// <summary>
    /// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public Task actualTask;
        public static DateTimeOffset dateTmp = DateTimeOffset.Now;

        public MainPage()
        {
            this.InitializeComponent();
            string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "dbtodo.sqlite");
            App db = App.Current as App;
            db.connection = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            db.connection.CreateTable<TodoDB>();
        }

        private void reload(object sender, RoutedEventArgs e)
        {
            App db = App.Current as App;
            SQLite.Net.TableQuery<TodoDB> task = db.connection.Table<TodoDB>();

            foreach (TodoDB theTask in task)
            {
                Grid pos;
                TextBlock date;
                TextBlock message;

                TodoList.Children.Add(pos = new Task
                {
                    Background = new SolidColorBrush(Colors.Black),
                    Margin = new Thickness(50, 50, 0, 0),
                    Width = 200,
                    Height = 200,
                    Id = theTask.Id,
                    Status = theTask.Status
                });

                pos.Children.Add(new TextBlock
                {
                    Text = theTask.Title,
                    Foreground = new SolidColorBrush(Colors.White),
                    TextAlignment = TextAlignment.Center,
                    FontWeight = FontWeights.ExtraBlack,
                    TextWrapping = TextWrapping.Wrap,
                    MaxHeight = 50,
                    Margin = new Thickness(0, 0, 0, 75)
                });

                pos.Children.Add(date = new TextBlock
                {
                    TextWrapping = TextWrapping.Wrap,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Margin = new Thickness(0, 75, 0, 0),
                    Text = theTask.DateT.ToString("d"),
                    Foreground = new SolidColorBrush(Colors.White),
                    FontWeight = FontWeights.ExtraBlack,
                });
            
                pos.Children.Add(message = new TextBlock
                {
                    TextAlignment = TextAlignment.Center,
                    TextWrapping = TextWrapping.Wrap,
                    Margin = new Thickness(0, 125, 0, 0),
                    Visibility = Visibility.Collapsed
                });

                if (theTask.Status)
                {
                    message.Text = "Finished";
                    message.FontSize = 30;
                    message.Foreground = new SolidColorBrush(Colors.LightGreen);
                    message.Visibility = Visibility.Visible;
                }

                pos.PointerPressed += new PointerEventHandler(Task_OnClick);
            }
        }

        private void Task_OnClick(object obj, PointerRoutedEventArgs ev)
        {
            if (this.actualTask != null)
                this.actualTask.Background = new SolidColorBrush(Colors.Black);
            Edit.Visibility = Visibility.Visible;
            Delete.Visibility = Visibility.Visible;
            ChangeStatus.Visibility = Visibility.Visible;
            this.actualTask = (Task)obj;
            this.actualTask.Background = new SolidColorBrush(Colors.DarkGray);
        }

        /*
        private void dueDate_OnDateChanged(CalendarDatePicker datePicker, CalendarDatePickerDateChangedEventArgs dateChanged)
        {
            if (dateTmp == dateChanged.NewDate)
                return;
            dateTmp = dateChanged.OldDate.Value;
            datePicker.Date = dateChanged.OldDate;
        }*/

        private void Add_Click(object sender, RoutedEventArgs e)
        {
            Frame.Navigate(typeof(AddTask));
        }

        private void Status_Click(object sender, RoutedEventArgs e)
        {
            App db = App.Current as App;
            TodoDB status = db.connection.Query<TodoDB>("SELECT * FROM TodoDB WHERE Id =" + this.actualTask.Id).FirstOrDefault();
            //status.Status = !status.Status;
            if (status.Status)
            {
                status.Status = false;
            }
            else
            {
                status.Status = true;
            }
            db.connection.Update(status);
            Frame.Navigate(typeof(MainPage));
        }

        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            string title = "Do you want delete this task ?";
            UICommand delete = new UICommand("Delete");
            UICommand cancel = new UICommand("Cancel");

            MessageDialog dialogMessage = new MessageDialog(title);
            dialogMessage.Commands.Add(delete);
            dialogMessage.Commands.Add(cancel);
            IUICommand command = await dialogMessage.ShowAsync();

            if (command != cancel)
            {
                App db = App.Current as App;
                db.connection.Query<TodoDB>("DELETE FROM TodoDB WHERE Id =" + this.actualTask.Id);
            }
            Frame.Navigate(typeof(MainPage));
        }

        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            App db = App.Current as App;
            db.CurrentObj = db.connection.Query<TodoDB>("SELECT * FROM TodoDB WHERE Id =" + this.actualTask.Id).FirstOrDefault();
            Frame.Navigate(typeof(EditTask));
        }
    }
}
<file_sep>/DOT_cardGames_2017/cardGame/cardGame/ChatServerHandler.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Groups;
using Newtonsoft.Json;

namespace cardGame
{
    public class ChatServerHandler : SimpleChannelInboundHandler<string>
    {
        static volatile IChannelGroup group;
        private static Blackjack _bj = new Blackjack();

        public override void ChannelActive(IChannelHandlerContext contex)
        {
            IChannelGroup g = group;
            if (g == null)
            {
                lock (this)
                {
                    if (group == null)
                    {
                        g = group = new DefaultChannelGroup(contex.Executor);
                    }
                }
            }
            
            contex.WriteAndFlushAsync("Welcome to BLACKJACK !\r\n");

            g.Add(contex.Channel);
            _bj.AddPlayer(contex);
        }

        class EveryOneBut : IChannelMatcher
        {
            readonly IChannelId id;

            public EveryOneBut(IChannelId id)
            {
                this.id = id;
            }

            public bool Matches(IChannel channel) => channel.Id != this.id;
        }

        protected override void ChannelRead0(IChannelHandlerContext contex, string msg)
        {
            ProtocolJson pj = JsonConvert.DeserializeObject<ProtocolJson>(msg);
            Console.WriteLine("Server receive : " + pj.message + "\n at : " + pj.messageDate + "\n from : " + contex.Channel.RemoteAddress);
            
            //send message to all but this one
            //string broadcast = string.Format("[{0}] {1}\n", contex.Channel.RemoteAddress, pj.message);
            //string response = string.Format("[you] {0}\n", pj.message);

            //group.WriteAndFlushAsync(broadcast, new EveryOneBut(contex.Channel.Id));
            //contex.WriteAndFlushAsync(response);

            if (string.Equals("bye", pj.message, StringComparison.OrdinalIgnoreCase))
            {
                _bj.RemovePlayerByContex(contex);
                contex.CloseAsync();
            }
            else
            {
                _bj.BlackjackHandler(contex, pj.message);
            }
        }

        public override void ChannelReadComplete(IChannelHandlerContext ctx) => ctx.Flush();

        public override void ExceptionCaught(IChannelHandlerContext ctx, Exception e)
        {
            Console.WriteLine("{0}", e.StackTrace);
            ctx.CloseAsync();
        }

        public override bool IsSharable => true;

        internal Program Program
        {
            get => default(Program);
            set
            {
            }
        }
    }
}
<file_sep>/DOT_cardGames_2017/cardGame/cardGame/Player.cs
using DotNetty.Transport.Channels;
using System.Collections.Generic;

namespace cardGame
{
    public class Player
    {
        private IChannelHandlerContext _contex;
        private string _name;
        private bool _hasPlay;
        private Hand _hand = new Hand();

        public Player(IChannelHandlerContext contex, string name)
        {
            _contex = contex;
            _name = name;
            _hasPlay = false;
        }

        public Hand Hand
        {
            get => default(Hand);
            set
            {
            }
        }

        public IChannelHandlerContext GetContex() => _contex;

        public string GetName() => _name;

        public void Write(string msg) => _contex.WriteAndFlushAsync("[Server]: " + msg + "\r\n");

        public void InvalidCommand() => _contex.WriteAndFlushAsync("[Server]: invalid command\r\n");

        public void TakeCard(Card card, int index = 0) => _hand.TakeCard(card, index);

        public void ClearHand() => _hand.ClearHand();

        public int GetHandValue(int index = 0) => _hand.GetHandValue(index);

        public void DisplayHand(int index = 0) => Write(_hand.GetDisplayHandMsg(index));

        public bool IsBusted(int index = 0) => _hand.IsBusted(index);

        public List<Card> GetHand(int index = 0) => _hand.GetHand(index);

        public bool GetHasPlay() => _hasPlay;

        public void SetHasPlay(bool b) => _hasPlay = b;

        public void SplitCard(int index = 0) => _hand.SplitCard(index);

        //Ask what to do
        public void AskPlayerAction(int index = 0)
        {          
            Write(_hand.GetPlayerActionMsg());
        }

        public bool IsHandEmpty()
        {
            return _hand.IsEmpty();
        }
    }
}