コード例 #1
0
        public async Task <IActionResult> Mail()//发送邮件
        {
            if (judge())
            {
                var mails = await mailBll.GetEntities(n => n.id > 0).ToListAsync();


                foreach (mail k in mails)
                {
                    SendMail.Mail(k.smail, "亲爱的" + k.uname + ",班委已开启青年大学习截图系统,请及时提交截图,提交地址:www.baidu.com");
                }
                return(Content("<script>alert('全部邮件发送成功');window.location.href='/Home/Index';</script>", "text/html", System.Text.Encoding.UTF8));
            }
            return(non());
        }
コード例 #2
0
        private ActionResult RedirectToLocal(string returnUrl, string id = null, string Ip = null, string Mac = null, string location = null, string Email = null)
        {
            var SessionaData = ValueController.GetSession(id);

            if (Url.IsLocalUrl(returnUrl))
            {
                if (SessionaData.IPAdressWhiteList)
                {
                    var rx = CheckIpWhiteList(id, Ip, Mac, location);
                    if (rx == 0)
                    {
                        AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                        return(View("IPErrorPage"));
                    }
                }
                return(Redirect(returnUrl));
            }
            // var userId = User.Identity.GetUserId();
            ValueController vc = new ValueController();


            if (SessionaData.DetectIP)
            {
                var res = ValueController.CheckIPAdress24(Ip, id);
                if (res == false)
                {
                    var data1 = ModelManager.PostSecurityData(id, Ip, Mac, location);
                    //SendMail obj = new SendMail();
                    SendMail.Mail(Email, "You are login with Ip Adress " + Ip + ". Is it you!");
                }
            }
            else if (SessionaData.IPAdressWhiteList)
            {
                var rx = CheckIpWhiteList(id, Ip, Mac, location);
                if (rx == 0)
                {
                    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                    return(View("IPErrorPage"));
                }
            }
            var data = ModelManager.PostSecurityData(id, Ip, Mac, location);

            vc.PostSessionToken();
            vc.PostActivityLog(id, "Login", "Succeed");
            return(RedirectToAction("Index", "Dashboard"));
        }
コード例 #3
0
        public async Task <IActionResult> SendMail([FromForm] MailCreateDto mailCreateDto)
        {
            try
            {
                string body = "<b>Ad Soyad:</b>" + mailCreateDto.Name + "<br/>" + "<b>Mail adresim:</b>" + mailCreateDto.Mail + "<br/>" + mailCreateDto.Content;
                mailCreateDto.Mail = "*****@*****.**";
                mailCreateDto.Name = "uğur mamak";
                SendMail send = new SendMail();
                send.Mail(mailCreateDto, body);
            }
            catch (Exception ex)
            {
                return(BadRequest("Mesaj iletirken hata oluştu."));

                throw ex;
            }
            return(Ok("Mesajınız iletildi"));
        }
コード例 #4
0
        public static void handle_clients(object o)
        {
            MySqlConnection connection = new MySqlConnection("datasource=mysql-quickgamefinder.alwaysdata.net; port=3306;Initial Catalog='quickgamefinder_dev';username=189919;password=Yujilaosyalere94");


            try
            {
                if (dbonline == false)
                {
                    Log("Connexion a la DB...", Lt.SERVEUR);
                    connection.Open();
                    Log("Connecté !", Lt.SERVEUR);
                    //OnlineStats.GetStats(connection);
                    dbonline = true;
                }
            }
            catch (Exception e)
            {
                Log(e.ToString(), Lt.ERREUR);
            }
            int       id = (int)o;
            TcpClient client;

            lock (_lock) client = list_clients[id];
            Log("Nouvelle ouverture du logiciel", Lt.OUVERTURE);
            string zpassword = "******";
            int    groupID   = 0;

            while (true)
            {
                Console.Title = "QuickGameFinder - Server [" + OnlineStats._onlineplayers.ToString() + " Online players]";
                try {
                    #region sys

                    NetworkStream stream = client.GetStream();
                    byte[]        buffer = new byte[1024];

                    int byte_count = stream.Read(buffer, 0, buffer.Length);

                    if (byte_count == 0)
                    {
                        break;
                    }

                    string data = Encoding.ASCII.GetString(buffer, 0, byte_count);
                    Log(data, Lt.SERVEUR);
                    #endregion

                    if (data.Contains("sendglobal") && data.Contains(zpassword))
                    {
                        string[] splitter = data.Split('|');
                        string   msg      = splitter[1];
                        broadcast("notif|" + msg);
                    }
                    if (data.Contains("sendnotif") && data.Contains(zpassword))
                    {
                        string[]  splitter = data.Split('|');
                        string    username = splitter[1];
                        string    msg      = splitter[2];
                        TcpClient clients  = new TcpClient();
                        byte[]    msgs     = Encoding.ASCII.GetBytes("notifsuccess");
                        stream.Write(msgs, 0, msgs.Length);

                        foreach (User u in ServerLists.users)
                        {
                            if (u.username == username)
                            {
                                clients = u.tcp_id;
                                Console.WriteLine("Envoie de la notification a " + username + "(" + u.tcp_id.ToString() + ")", Lt.SERVEUR);
                            }
                        }
                        NetworkStream sstream = clients.GetStream();
                        byte[]        imsg    = Encoding.ASCII.GetBytes("notif|" + msg);
                        stream.Write(imsg, 0, imsg.Length);
                    }
                    if (data.Contains("kick") && data.Contains(zpassword))
                    {
                        string[] splitter = data.Split('|');
                        string   user     = splitter[1];

                        TcpClient clients = new TcpClient();
                        foreach (User u in ServerLists.users)
                        {
                            if (u.username == user)
                            {
                                clients = u.tcp_id;
                            }
                        }

                        NetworkStream sstream = clients.GetStream();
                        byte[]        imsg    = Encoding.ASCII.GetBytes("quit");
                        stream.Write(imsg, 0, imsg.Length);
                    }
                    if (data.Contains("kickall") && data.Contains(zpassword))
                    {
                        string[] splitter = data.Split('|');

                        broadcast("quitall");
                    }
                    if (data.Contains("AuthRequest"))
                    {
                        string[]  splitter = data.Split('|');
                        string    username = splitter[1];
                        string    password = splitter[2];
                        TcpClient clients  = new TcpClient();
                        clients = client;
                        byte[] msg = Auth(connection, username, password, clients);

                        stream.Write(msg, 0, msg.Length);
                    }
                    if (data.Contains("RegisterRequest"))
                    {
                        TcpClient clients = new TcpClient();
                        clients = client;
                        string[] splitter = data.Split('|');
                        string   username = splitter[1];
                        string   email    = splitter[2];
                        string   password = splitter[3];
                        if (connection.State == ConnectionState.Closed)
                        {
                            connection.Open();
                        }
                        MySqlDataAdapter checkids = new MySqlDataAdapter("SELECT * FROM users WHERE username = '******'", connection);
                        DataTable        table    = new DataTable();
                        checkids.Fill(table);
                        byte[] toreturn  = null;
                        string toconvert = "";
                        //Log("Tentative d'inscription...");
                        if (table.Rows.Count == 0)
                        {
                            MySqlDataAdapter checkidss = new MySqlDataAdapter("SELECT * FROM users WHERE email = '" + email + "'", connection);
                            DataTable        tables    = new DataTable();
                            checkidss.Fill(tables);
                            if (tables.Rows.Count == 0)
                            {
                                MySqlCommand c = new MySqlCommand("INSERT INTO `users` (`username`, `email`, `password`, `rank`, `ban`) VALUES ('" + username + "', '" + email + "', '" + password + "', 'free', '0')", connection);
                                c.ExecuteNonQuery();
                                toconvert = "regsuccess";
                                Log(username, Lt.INSCRIPTION);
                            }
                            else
                            {
                                toconvert = "regfailed";
                                //Log("Impossible de procéder a l'inscription");
                            }
                        }
                        else
                        {
                            toconvert = "regfailed";
                            //Log("Impossible de procéder a l'inscription");
                        }

                        toreturn = Encoding.ASCII.GetBytes(toconvert + "|" + username);
                        // con.Close();
                        Log(Encoding.ASCII.GetString(toreturn), Lt.SERVEUR);
                        NetworkStream nssss = clients.GetStream();
                        nssss.Write(toreturn, 0, toreturn.Length);
                        connection.Close();
                    }
                    if (data.Contains("DisconnectRequest"))
                    {
                        string[] splitter = data.Split('|');
                        string   username = splitter[1];
                        byte[]   yoloh    = Encoding.ASCII.GetBytes("disconnectsuccess");
                        Log(username, Lt.DECONNEXION);
                        try
                        {
                            stream.Write(yoloh, 0, yoloh.Length);
                        }
                        catch (Exception e)
                        {
                            Log(e.ToString(), Lt.ERREUR);
                        }

                        User u = new User();
                        foreach (User user in ServerLists.users)
                        {
                            if (user.username == username)
                            {
                                u = user;
                                ServerLists.users.Remove(user);
                            }
                        }

                        foreach (Group g in ServerLists.groups)
                        {
                            if (g.users.Contains(u))
                            {
                                g.users.Remove(u);
                                foreach (User gu in g.users)
                                {
                                    NetworkStream givedc = gu.tcp_id.GetStream();
                                    byte[]        b      = Encoding.ASCII.GetBytes("PlayerDisconnect|" + username);
                                    givedc.Write(b, 0, b.Length);
                                }
                            }
                            if (g.author == username)
                            {
                                ServerLists.groups.Remove(g);
                            }
                        }
                        if (username != "")
                        {
                            OnlineStats._onlineplayers--;
                            broadcast("OP|" + OnlineStats._onlineplayers.ToString() + "|" + OnlineStats._onlinegroups.ToString());
                            broadcast(Encoding.ASCII.GetString(ServerLists.GetGroups()));
                        }
                    }

                    if (data.Contains("CreateGroupRequest"))//CreateGroupRequest|author|actualplayers|desiredplayers|public/private|gameIDs|groupname|groupdesc
                    {
                        string[] splitter       = data.Split('|');
                        string   author         = splitter[1];
                        int      actualplayers  = int.Parse(splitter[2]);
                        int      desiredplayers = int.Parse(splitter[3]);
                        string   _public        = splitter[4];
                        string   gameID         = splitter[5];
                        string   roomname       = splitter[6];
                        string   roomdesc       = splitter[7];

                        string rank = "";
                        Log("Recherche du rank de " + author + " (" + ServerLists.users.Count.ToString() + ")", Lt.SERVEUR);
                        foreach (User u in ServerLists.users)
                        {
                            if (u.username == author)
                            {
                                rank = u.rank;
                            }
                        }
                        Random rnd = new Random();
                        groupID = rnd.Next(1, 99999999);
                        foreach (Group g in ServerLists.groups)
                        {
                            if (g.author == author)
                            {
                                ServerLists.groups.Remove(g);
                            }
                        }
                        Group grp = new Group(roomname, roomdesc, author, actualplayers, desiredplayers, gameID, _public, groupID, rank);
                        ServerLists.groups.Add(grp);

                        Log("Groupe " + gameID + " créé par " + author + "(" + rank + ")", Lt.SERVEUR);
                        broadcast(Encoding.ASCII.GetString(ServerLists.GetGroups()));
                        OnlineStats._onlinegroups++;
                        broadcast("OP|" + OnlineStats._onlineplayers.ToString() + "|" + OnlineStats._onlinegroups.ToString());
                    }
                    if (data.Contains("MissingGame"))
                    {
                        string[] splitter = data.Split('|');
                        string   game     = splitter[1];
                        string   sender   = splitter[2];
                        Log("Jeu manquant : " + game + " , rapport envoyé par " + sender, Lt.SERVEUR);
                        string content = "Le joueur " + sender + " a reporté le jeu '" + game + "' comme manquant.";
                        SendMail.Mail(content, SendMail.MailType.MISSINGGAME);
                    }
                    if (data.Contains("GetGroups"))
                    {
                        byte[] msg = ServerLists.GetGroups();
                        stream.Write(msg, 0, msg.Length);
                        Log("Groupes envoyés (" + ServerLists.groups.Count.ToString() + ")", Lt.SERVEUR);
                        broadcast("OP|" + OnlineStats._onlineplayers.ToString() + "|" + OnlineStats._onlinegroups.ToString());
                    }
                    if (data.Contains("Error"))
                    {
                        string[] splitter = data.Split('|');

                        Log(splitter[1], Lt.ERREUR);
                    }
                    if (data.Contains("RemoveRoom"))
                    {
                        string[] splitter = data.Split('|');
                        int      room     = int.Parse(splitter[1]);

                        foreach (Group g in ServerLists.groups)
                        {
                            if (g.roomiD == room)
                            {
                                string author = g.author;
                                foreach (User u in g.users)
                                {
                                    if (u.username == author)
                                    {
                                        NetworkStream remove  = u.tcp_id.GetStream();
                                        byte[]        message = Encoding.ASCII.GetBytes("RoomDisbanded");
                                        remove.Write(message, 0, message.Length);
                                        g.users.Remove(u);
                                    }
                                }
                                foreach (User u in g.users)
                                {
                                    NetworkStream remove  = u.tcp_id.GetStream();
                                    byte[]        message = Encoding.ASCII.GetBytes("RoomKicked|nextriesh");
                                    remove.Write(message, 0, message.Length);
                                }
                                Group.DisbandGroup(room);
                                broadcast(Encoding.ASCII.GetString(ServerLists.GetGroups()));
                            }
                        }
                    }
                    if (data.Contains("SendMessageRequest"))
                    {
                        string[] splitter = data.Split('|');
                        string   content  = splitter[1];
                        string   auteur   = splitter[2];
                        int      room     = int.Parse(splitter[3]);

                        foreach (Group r in ServerLists.groups)
                        {
                            if (r.roomiD == room)
                            {
                                foreach (User u in r.users)
                                {
                                    NetworkStream s       = u.tcp_id.GetStream();
                                    byte[]        buffers = Encoding.ASCII.GetBytes("NewMessage|" + content + "|" + auteur);
                                    s.Write(buffers, 0, buffers.Length);
                                }
                            }
                        }
                    }
                    if (data.Contains("JoinCreatedGroup"))
                    {
                        string[] splitter = data.Split('|');
                        string   user     = splitter[1];
                        User     u        = new User();
                        foreach (User usesr in ServerLists.users)
                        {
                            if (usesr.username == user)
                            {
                                u = usesr;
                            }
                        }
                        int done = 0;

                        foreach (Group r in ServerLists.groups)
                        {
                            if (r.author == user)
                            {
                                r.users.Add(u);
                                byte[] boffer = Encoding.ASCII.GetBytes("JoinSuccess|" + user + "/free;" + "|" + r.roomname + "|" + r.roomdescription + "|" + r.author + "|" + user + "|" + r.roomiD.ToString());
                                Log("JoinSuccess|" + user + "/free;" + "|" + r.roomname + "|" + r.roomdescription + "|" + r.author + "|" + user, Lt.SERVEUR);
                                NetworkStream sss = u.tcp_id.GetStream();
                                sss.Write(boffer, 0, boffer.Length);
                                done = 1;
                            }
                            if (done == 1)
                            {
                                break;
                            }
                        }
                    }
                    if (data.Contains("RoomKick"))
                    {
                        string[] splitter = data.Split('|');
                        string   tokick   = splitter[1];
                        string   admin    = splitter[2];
                        foreach (User u in ServerLists.users)
                        {
                            if (u.username == tokick)
                            {
                                NetworkStream sss   = u.tcp_id.GetStream();
                                byte[]        tobuf = Encoding.ASCII.GetBytes("RoomKicked|" + admin);
                                sss.Write(tobuf, 0, tobuf.Length);
                                Log(admin + " a kick " + tokick, Lt.SERVEUR);
                                foreach (Group r in ServerLists.groups)
                                {
                                    if (r.author == admin)
                                    {
                                        try
                                        {
                                            r.playercounter--;
                                            r.users.Remove(u);
                                            foreach (User use in r.users)
                                            {
                                                NetworkStream ss     = use.tcp_id.GetStream();
                                                byte[]        tobufs = Encoding.ASCII.GetBytes("PlayerKicked|" + tokick);
                                                ss.Write(tobufs, 0, tobufs.Length);
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (data.Contains("JoinRoomRequest"))
                    {
                        string[] splitter = data.Split('|');
                        int      roomid   = int.Parse(splitter[1]);
                        string   username = splitter[2];
                        User     user     = new User();
                        #region finduser
                        foreach (User u in ServerLists.users)
                        {
                            if (u.username == username)
                            {
                                user.username = u.username;
                                user.tcp_id   = u.tcp_id;
                                user.rank     = u.rank;
                            }
                        }
                        Log(user.username, Lt.SERVEUR);
                        #endregion
                        #region findroom

                        foreach (Group r in ServerLists.groups)
                        {
                            if (r.roomiD == roomid)
                            {
                                if (r.playercounter != r.desiredplayers)
                                {
                                    r.playercounter++;


                                    r.users.Add(user);
                                    string        users  = r.GetUsers();
                                    byte[]        boffer = Encoding.ASCII.GetBytes("JoinSuccess|" + users + "|" + r.roomname + "|" + r.roomdescription + "|" + r.author + "|" + username + "|" + r.roomiD.ToString());
                                    NetworkStream sss    = user.tcp_id.GetStream();
                                    sss.Write(boffer, 0, boffer.Length);
                                    Log("JoinSuccess|" + users + "|" + r.roomname + "|" + r.roomdescription + "|" + r.author + "|" + username + "|" + r.roomiD.ToString(), Lt.SERVEUR);
                                    Log("Taille salon: (" + r.playercounter.ToString() + "/" + r.desiredplayers.ToString() + ")", Lt.SERVEUR);

                                    foreach (User u in r.users)
                                    {
                                        if (r.users.Count > 0)
                                        {
                                            if (u.username != username)
                                            {
                                                broadcast("PlayerJoined|" + username + "|" + user.rank + "|" + r.roomiD.ToString());

                                                Log("PlayerJoined|" + username + "|" + user.rank + "|" + r.roomiD.ToString(), Lt.SERVEUR);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    Log("Salon plein (" + r.playercounter.ToString() + "/" + r.desiredplayers.ToString() + ")", Lt.ERREUR);

                                    //JoinSuccess|user1/premium;user2/free;user3/free;|roomtitle|roomdesc|author
                                    NetworkStream s = user.tcp_id.GetStream();

                                    string users   = r.GetUsers();
                                    byte[] buffers = Encoding.ASCII.GetBytes("RoomFull");
                                    s.Write(buffers, 0, buffers.Length);
                                }
                            }
                        }
                        #endregion
                    }
                    #region endsys
                }

                catch
                {
                    break;
                }
            }

            lock (_lock) list_clients.Remove(id);
            client.Client.Shutdown(SocketShutdown.Both);
            client.Close();
            #endregion
        }
コード例 #5
0
        public ActionResult BuyBitcoin(BuyViewModel obj)
        {
            if (!ModelState.IsValid)
            {
                var d1 = CoinsMarketValueController.GetMarkupWithCoinId();
                foreach (var r in d1)
                {
                    switch (r.Key)
                    {
                    case 101: mark101 = r.Value; break;

                    case 102: mark102 = r.Value; break;

                    case 103: mark103 = r.Value; break;

                    case 104: mark104 = r.Value; break;

                    case 105: mark105 = r.Value; break;

                    case 106: mark106 = r.Value; break;
                    }
                }

                try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
                try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
                try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
                try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
                try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
                try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }

                ViewBag.Coinlist = Session["a"];
                return(View(obj));
            }

            var userId = User.Identity.GetUserId();

            obj.UserId = userId;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(url + "Transaction/Buy");

                //HTTP POST
                var postTask = client.PostAsJsonAsync(url + "Transaction/Buy", obj);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    //return RedirectToAction("Index");
                    EmailNotification en = Session["Notification"] as EmailNotification;
                    if (en.Buy == true)
                    {
                        string uname = Session["UserName"] as string;
                        string Email = Session["Email"] as string;
                        string res   = "Hi," + uname + " you sent buy coin requist. ";
                        // SendMail a = new Blockchaninaccounts.App_Start.SendMail();
                        SendMail.Mail(Email, res);
                    }
                    ViewBag.msg = "Buy Amount Saved Successfully";

                    var d2 = CoinsMarketValueController.GetMarkupWithCoinId();
                    foreach (var r in d2)
                    {
                        switch (r.Key)
                        {
                        case 101: mark101 = r.Value; break;

                        case 102: mark102 = r.Value; break;

                        case 103: mark103 = r.Value; break;

                        case 104: mark104 = r.Value; break;

                        case 105: mark105 = r.Value; break;

                        case 106: mark106 = r.Value; break;
                        }
                    }

                    try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
                    try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
                    try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
                    try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
                    try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
                    try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }
                    ModelState.Clear();
                    return(View("DashboardSuccess"));
                }
                //else
                //{
                //    ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
                //}
            }

            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
            //ModelState.Clear();
            ViewBag.Coinlist = Session["a"];

            var d = CoinsMarketValueController.GetMarkupWithCoinId();

            foreach (var r in d)
            {
                switch (r.Key)
                {
                case 101: mark101 = r.Value; break;

                case 102: mark102 = r.Value; break;

                case 103: mark103 = r.Value; break;

                case 104: mark104 = r.Value; break;

                case 105: mark105 = r.Value; break;

                case 106: mark106 = r.Value; break;
                }
            }

            try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
            try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
            try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
            try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
            try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
            try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }
            return(View(obj));
        }
コード例 #6
0
        [HttpPost("register")] //kullanıcı bilgileri ve resim bilgisi gelmektedir.
                               // public async Task<IActionResult> Register([FromForm] IFormFile image, [FromForm] UserForRegisterDto userForRegisterDto)
        public async Task <IActionResult> Register([FromForm] UserForRegisterDto userForRegisterDto)
        {
            var userExists = _authService.UserExists(userForRegisterDto.Email);//Kullanıcının girdiği email bilgisinin Db'de olup olamdığını kontrol ettik.

            //userExists'in geridönüş değeri SuccessResult'tır. Buradan işlemin başarılı olup olmadığını kontrol edebiliriz.
            if (!userExists.Success)
            {
                return(BadRequest(userExists.Message));
            }

            string Id        = Guid.NewGuid().ToString();                           //resimlere guid Id şeklinde isim ataması yaptım.
            var    resimler  = Path.Combine(_environment.WebRootPath, "userImage"); //dizin bilgisi
            string imageName = $"{Id}.jpg";                                         //Db ye kaydedilecek olan resimlerin ismi

            if (userForRegisterDto.Image == null)
            {
                //return BadRequest("Resim Bilgisi Boş");
                imageName = "profileImage.jpg";
            }

            string password = "";

            if (userForRegisterDto.processType == "SystemAdmin")
            {
                RandomPassword pass = new RandomPassword();
                password = pass.password();
                userForRegisterDto.Password = password;
            }

            var registerResult = _authService.Register(userForRegisterDto, userForRegisterDto.Password, imageName);
            var result         = _authService.CreateAccessToken(registerResult.Data);//registerResult'ın döndüğü Data(User) bilgisini token üretmek için parametre olarak verdim.

            if (userForRegisterDto.Image != null)
            {
                if (userForRegisterDto.Image.Length > 0)
                {
                    using (var fileStream = new FileStream(Path.Combine(resimler, imageName), FileMode.Create))
                    {
                        await userForRegisterDto.Image.CopyToAsync(fileStream);
                    }
                }
            }

            if (registerResult.Success)
            {
                if (password != "")
                {
                    string body = "Merhaba " + userForRegisterDto.FirstName + " " + userForRegisterDto.LastName + "<br/>" + " Başvurunuz dikkate alınarak size hesap oluşturulmuştur." +
                                  "  Sisteme giriş yapmak için <br/> bize iletmiş olduğunuz mail adresini:" + "<b>" + userForRegisterDto.Email + "</b>" + "<br/> ve şifre olarak: " + "<b>" + password + "<b/><br/>" + "kullanabilirsiniz." +
                                  "<br/>Sisteme giriş yaptıktan sonra profil resminizi ve şifrenizi güncelleyebilirsiniz.";

                    MailCreateDto gonder = new MailCreateDto {
                        Content = body,
                        Mail    = userForRegisterDto.Email,
                        Name    = userForRegisterDto.FirstName + " " + userForRegisterDto.LastName,
                        Subject = "Adminlik ve Opetatör başvurusu"
                    };

                    SendMail send = new SendMail();
                    send.Mail(gonder, body);
                }
                return(Ok(result.Data));
            }
            return(BadRequest(result.Message));
        }
コード例 #7
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            ApplicationUser user;
            bool            IsEmail = IsValidEmail(model.Email);

            if (IsEmail)
            {
                user = await UserManager.FindByEmailAsync(model.Email);
            }
            else
            {
                user = await UserManager.FindByNameAsync(model.Email);
            }

            //Session["ID"] = Session.SessionID;
            //if (user != null)
            //{
            //    if (!await UserManager.IsEmailConfirmedAsync(user.Id))
            //    {
            //        string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account-Resend");
            //        ViewBag.errorMessage = "You must have a confirmed email to log on. please check your Email to confirm email.";
            //        return View("Error");
            //    }

            //}

            // Require the user to have a confirmed email before they can log on.
            //var user = await UserManager.FindByNameAsync(model.Email);
            if (user != null)
            {
                if (!await UserManager.IsEmailConfirmedAsync(user.Id))
                {
                    string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account-Resend");

                    ViewBag.errorMessage = "You must have a confirmed email to log on.";
                    return(View("Error"));
                }
            }
            if (user == null)
            {
                ModelState.AddModelError("", "Please Enter Correct Email or Username.");
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                if (1 == 1)
                {
                    string res = "Hi, you are login with " + get();
                    // SendMail a = new Blockchaninaccounts.App_Start.SendMail();
                    SendMail.Mail(user.Email, res);
                }
                ValueController vc   = new ValueController();
                var             res1 = vc.PostAddress(user.Id);
                var             v    = GetNotification(user.Id);
                Session["Notification"]        = v as EmailNotification;
                SecurityCenterController.Email = user.Email;
                SecurityCenterController.Id    = user.Id;
                string Ip       = GetIPAddress();
                string Mac      = GetMacAddress();
                string location = null;
                Session["Email"]    = user.Email;
                Session["UserName"] = user.UserName;
                if (user.GoogleAuthetication == true)
                {
                    return(RedirectToAction("GoogleCodeVarification"));
                }



                return(RedirectToLocal(returnUrl, user.Id, Ip, Mac, location, user.Email));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                Session["Email"]               = user.Email;
                Session["UserName"]            = user.UserName;
                SecurityCenterController.Email = user.Email;
                SecurityCenterController.Id    = user.Id;
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Please Enter Correct Password.");
                return(View(model));
            }
        }
コード例 #8
0
        // [ActionName("PostSaveReceive")]
        public ActionResult RecieveBitcoin(RecieveBitcoinViewModel obj)
        {
            // string CoinName = Request.Form["CoinTypeId"];
            string CoinName = Request["CoinName"];

            obj.QRCode             = Request["Address"];
            obj.DestinationBitcoin = "Sample";
            if (!ModelState.IsValid)
            {
                var d1 = CoinsMarketValueController.GetMarkupWithCoinId();
                foreach (var r in d1)
                {
                    switch (r.Key)
                    {
                    case 101: mark101 = r.Value; break;

                    case 102: mark102 = r.Value; break;

                    case 103: mark103 = r.Value; break;

                    case 104: mark104 = r.Value; break;

                    case 105: mark105 = r.Value; break;

                    case 106: mark106 = r.Value; break;
                    }
                }

                try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
                try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
                try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
                try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
                try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
                try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }
                return(View(obj));
            }

            var userId = User.Identity.GetUserId();

            obj.UserId = userId;
            // using (var scope = new TransactionScope())
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(url + "transaction/ReceiveaPost");


                    //HTTP POST
                    var postTask = client.PostAsJsonAsync(url + "transaction/ReceiveaPost", obj);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        string message = "Hi, this " + Session["Email"] as string + " wants " + obj.AmtInCoins + " " + CoinName + " and Coin Address is " + Request["Address"];
                        SendMail.Mail(obj.RecievedToEmail, message);
                        //return RedirectToAction("Index");
                        EmailNotification en = Session["Notification"] as EmailNotification;
                        if (en != null)
                        {
                            if (en.Receive == true)
                            {
                                string uname = Session["UserName"] as string;
                                string Email = Session["Email"] as string;
                                string res   = "Hi," + uname + " you sent Recieve coin requist. ";
                                //SendMail a = new Blockchaninaccounts.App_Start.SendMail();
                                SendMail.Mail(Email, res);
                            }
                        }
                        ViewBag.msg = "Receive Request successful...!";

                        var d2 = CoinsMarketValueController.GetMarkupWithCoinId();
                        foreach (var r in d2)
                        {
                            switch (r.Key)
                            {
                            case 101: mark101 = r.Value; break;

                            case 102: mark102 = r.Value; break;

                            case 103: mark103 = r.Value; break;

                            case 104: mark104 = r.Value; break;

                            case 105: mark105 = r.Value; break;

                            case 106: mark106 = r.Value; break;
                            }
                        }

                        try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
                        try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
                        try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
                        try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
                        try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
                        try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }
                        ModelState.Clear();
                        return(View("DashboardSuccess"));
                    }
                    //else
                    //{
                    //    ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
                    //}
                }
            }

            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
            // ModelState.Clear();
            ViewBag.Coinlist = Session["a"];

            var d = CoinsMarketValueController.GetMarkupWithCoinId();

            foreach (var r in d)
            {
                switch (r.Key)
                {
                case 101: mark101 = r.Value; break;

                case 102: mark102 = r.Value; break;

                case 103: mark103 = r.Value; break;

                case 104: mark104 = r.Value; break;

                case 105: mark105 = r.Value; break;

                case 106: mark106 = r.Value; break;
                }
            }

            try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
            try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
            try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
            try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
            try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
            try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }

            return(View(obj));
        }