示例#1
0
        public UserGroup GetUsersInGroup(int group_id)
        {
            UserGroup ug = new UserGroup();

            string sql = $"Select group_id, user_id FROM users_group WHERE group_id={group_id}";

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = myConnection;
            cmd.CommandText = sql;

            using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ug.group_id = reader.GetInt16(0);
                        dbUser us = new dbUser();
                        us.id = reader.GetInt16(1);
                        ug.users.Add(us);
                    }
                }
            }

            for (int i = 0; i < ug.users.Count; i++)
            {
                ug.users[i] = GetUserSourceInfo(ug.users[i].id);
            }

            return(ug);
        }
示例#2
0
        public List <dbUser> GetOnlyUsers(int group_id)
        {
            List <dbUser> users = new List <dbUser>();

            string sql = $"SELECT users.id FROM users, users_group WHERE users_group.group_id={group_id} AND users_group.user_id = users.id AND users.is_bot=1";

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = myConnection;
            cmd.CommandText = sql;

            using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        dbUser us = new dbUser();
                        us.id = reader.GetInt16(0);
                        users.Add(us);
                    }
                }
            }
            return(users);
        }
示例#3
0
        public dbUser GetUserSourceInfo(int user_id)
        {
            dbUser us = new dbUser();

            string sql = $"SELECT users.id, users.name, sources.id, sources.upload_time FROM users,sources WHERE sources.user_id=users.id AND users.id={user_id} AND used=1 AND sources.status='ok'";

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = myConnection;
            cmd.CommandText = sql;

            using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        us.id   = reader.GetInt16(0);
                        us.name = reader.GetString(1);
                        us.compiledAndUsedSourceId = reader.GetInt16(2);
                        us.last_upload_time        = reader.GetInt32(3);
                    }
                }
            }
            return(us);
        }
示例#4
0
        private void SendSMS(string UserRole)
        {
            dbUser         dbUserData     = new dbUser();
            CommonFunction fnCommon       = new CommonFunction();
            DataSet        dsUserTypeData = new DataSet();

            //Get User Mobile based on Role
            dsUserTypeData = dbUserData.GetUserBasedOnRole(UserRole);
            if (dsUserTypeData.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow rows in dsUserTypeData.Tables[0].Rows)
                {
                    string UserMobileNo = rows["mobile1"].ToString();
                    if (string.IsNullOrEmpty(UserMobileNo))
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Mobile Number Not available, Please contact administrator');", true);
                        //  Response.Redirect("~/UserLogin.aspx");
                    }
                    else
                    {
                        string MobileMessage = "Document is sent to you for approval ";
                        fnCommon.sendsms("+91" + UserMobileNo, MobileMessage);
                    }
                }
                //}
            }
        }
示例#5
0
        private void SendSMS(string UserRole)
        {
            dbUser         dbUserData     = new dbUser();
            CommonFunction fnCommon       = new CommonFunction();
            DataSet        dsUserTypeData = new DataSet();

            //Get User Mobile based on Role
            dsUserTypeData = dbUserData.GetUserBasedOnRole(UserRole);
            if (dsUserTypeData.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow rows in dsUserTypeData.Tables[0].Rows)
                {
                    string UserMobileNo = rows["mobile1"].ToString();
                    if (string.IsNullOrEmpty(UserMobileNo))
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Mobile Number Not available, Please contact administrator');", true);
                        //  Response.Redirect("~/UserLogin.aspx");
                    }
                    else
                    {
                        string FromName = "Solicitor";
                        string DocNo    = LblDocNo.Text;
                        //string MobileMessage = "Document is sent to you for approval ";
                        //Document No. %%| DocNo ^{ "inputtype" : "text", "maxlength" : "20"}%% sent you from %%| FromName ^{ "inputtype" : "text", "maxlength" : "20"}%%
                        string MobileMessage = "Document No. " + DocNo + "  sent you from " + FromName;
                        fnCommon.sendsms("+91" + UserMobileNo, MobileMessage);
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('SMS Send to Head Office');", true);
                    }
                }
                //}
            }
        }
示例#6
0
        public ActionResult SaveUser(dbUser muser)
        {
            muser.RoleId = 2;
            db.dbUser.Add(muser);
            db.SaveChanges();
            var myimage = db.Gallery.ToList();

            ViewData["Mygallery"] = myimage;
            var res = db.Maghaleh.OrderByDescending(f => f.Id).Take(5).ToList();

            ViewData["Content"] = res;

            return(View("index"));
        }
示例#7
0
        private void SendSMS(string UserRole)
        {
            dbUser         dbUserData     = new dbUser();
            CommonFunction fnCommon       = new CommonFunction();
            DataSet        dsUserTypeData = new DataSet();

            //Get User Mobile based on Role
            dsUserTypeData = dbUserData.GetUserBasedOnRole(UserRole);
            if (dsUserTypeData.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow rows in dsUserTypeData.Tables[0].Rows)
                {
                    string UserMobileNo = rows["mobile1"].ToString();
                    if (string.IsNullOrEmpty(UserMobileNo))
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Mobile Number Not available, Please contact administrator');", true);
                        //  Response.Redirect("~/UserLogin.aspx");
                    }
                    else
                    {
                        string MobileMessage = "Document is sent to you for approval ";
                        fnCommon.sendsms("+91" + UserMobileNo, MobileMessage);
                    }
                }
            }
            //dbUserData.UserName = Session["UserName"].ToString();
            //string MobileNo = dbUserData.GetMobileNo();


            //String message = HttpUtility.UrlEncode("This is test Message from -- SEZTHANE");
            //using (var wb = new WebClient())
            //{
            //    byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
            //    {
            //    {"apikey" , "MK7fugiPrhQ-7bOiwEjRcBqziqL2eH9r6QITPtS2K6"},
            //    //{"numbers" , "919890037859"},
            //     {"numbers" , "919890037859"},
            //    {"message" , message},
            //    {"sender" , "SEZTHA"}
            //    });
            //    string result = System.Text.Encoding.UTF8.GetString(response);
            //    //return result;
            //}
        }
示例#8
0
        public List <Game> GetWaitGame(string type)
        {
            List <Game> games_list = new List <Game>();

            string sql = $"SELECT * FROM {type} WHERE status='wait'";

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = myConnection;
            cmd.CommandText = sql;

            using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Game sb = new Game();
                        sb.id       = reader.GetInt16(0);
                        sb.datetime = reader.GetInt32(1);
                        UserGroup ug = new UserGroup();
                        ug.group_id  = reader.GetInt16(2);
                        sb.usergroup = ug;
                        sb.status    = reader.GetString(3);
                        if (type == "sandbox")
                        {
                            dbUser us = new dbUser();
                            us.id      = reader.GetInt16(4);
                            sb.creator = us;
                        }
                        games_list.Add(sb);
                    }
                }
            }

            for (int i = 0; i < games_list.Count; i++)
            {
                games_list[i].usergroup = GetUsersInGroup(games_list[i].usergroup.group_id);
                games_list[i].creator   = GetUserSourceInfo(games_list[i].creator.id);
            }

            return(games_list);
        }
示例#9
0
        /// <summary>
        /// Создание игрока на основе данных из модели
        /// </summary>
        /// <param name="i"></param>
        User CreatePlayer(dbUser user)
        {
            User pplayer = new User();

            pplayer.ID   = user.id + "";
            pplayer.Name = user.name;

            pplayer.Points = 0;
            //    pplayer.Health = Config.player_health;
            pplayer.Health     = 1;
            pplayer.BangRadius = Config.bang_start_radius;
            pplayer.BombsCount = Config.player_bombs_count_start;

            pplayer.X = pseudoplayers[0].X;
            pplayer.Y = pseudoplayers[0].Y;
            pseudoplayers.RemoveAt(0);

            return(pplayer);
        }
    protected void Button_Save_Click(object sender, EventArgs e)
    {
        switch (Request.QueryString["action"])
        {
            case "add":
                if (TextBox_Password.Text == "" || TextBox_Password_Repeat.Text == "")
                {
                    Panel_Error.Visible = true;
                    Label_Error.Text = "Udfyld kodeord";
                }
                else
                {
                    dbUser newUser = new dbUser();
                    newUser.Name = TextBox_Name.Text;
                    newUser.Email = TextBox_Email.Text;
                    newUser.Password = Helpers.getHashSha256(TextBox_Password.Text, TextBox_Email.Text);
                    db.dbUsers.InsertOnSubmit(newUser);
                    db.SubmitChanges();

                    Response.Redirect("Users.aspx");
                }
                break;

            case "edit":
                dbUser editUser = db.dbUsers.First(u => u.Id.Equals(Request.QueryString["user_id"]));
                editUser.Name = TextBox_Name.Text;
                editUser.Email = TextBox_Email.Text;
                editUser.RoleId = Convert.ToInt32(DropDownList_Role.SelectedValue);
                if (TextBox_Password.Text != "" || TextBox_Password_Repeat.Text != "")
                {
                    editUser.Password = Helpers.getHashSha256(TextBox_Password.Text, TextBox_Email.Text);
                }
                db.SubmitChanges();
                Response.Redirect("Users.aspx");
                break;
        }
    }
	private void detach_dbUsers(dbUser entity)
	{
		this.SendPropertyChanging();
		entity.dbRole = null;
	}
	private void attach_dbUsers(dbUser entity)
	{
		this.SendPropertyChanging();
		entity.dbRole = this;
	}
 partial void DeletedbUser(dbUser instance);
 partial void UpdatedbUser(dbUser instance);
 partial void InsertdbUser(dbUser instance);
示例#16
0
        public async Task LoginAsync(string sUser, string sPassword, bool isNeedPop)
        {
            User user = new User
            {
                customers_email_address = sUser,
                customers_password      = sPassword
            };

            var currentUser = await App.oServiceManager.LoginAsync(user);

            if (!currentUser.success.Equals("1"))
            {
                await Application.Current.MainPage.DisplayAlert("Notificación", currentUser.message, "Aceptar");
            }
            else
            {
                dbUser dbUser = new dbUser
                {
                    customers_id            = currentUser.data[0].customers_id,
                    customers_firstname     = currentUser.data[0].customers_firstname,
                    customers_lastname      = currentUser.data[0].customers_lastname,
                    customers_dob           = currentUser.data[0].customers_dob,
                    customers_gender        = currentUser.data[0].customers_gender,
                    customers_picture       = currentUser.data[0].customers_picture,
                    customers_email_address = currentUser.data[0].customers_email_address,
                    customers_password      = currentUser.data[0].customers_password,
                    customers_telephone     = currentUser.data[0].customers_telephone,
                    customers_fax           = currentUser.data[0].customers_fax,
                    customers_newsletter    = currentUser.data[0].customers_newsletter,
                    fb_id     = currentUser.data[0].fb_id,
                    google_id = currentUser.data[0].google_id,
                    isActive  = currentUser.data[0].isActive,
                    customers_default_address_id = currentUser.data[0].customers_default_address_id
                };

                await App.DataBase.SaveUser(dbUser);

                Settings.isLogin    = true;
                Settings.IdCustomer = currentUser.data[0].customers_id;
                Settings.UserName   = currentUser.data[0].customers_firstname;
                Settings.UserEmail  = currentUser.data[0].customers_email_address;

                if (isNeedPop)
                {
                    var mdp     = (Application.Current.MainPage as MasterDetailPage);
                    var navPage = mdp.Detail as NavigationPage;
                    await navPage.PopAsync();
                }
                else
                {
                    Application.Current.MainPage = new MasterDetailPage()
                    {
                        Master = new MasterPage()
                        {
                            Title = "Menú"
                        },
                        Detail = new NavigationPage(new HomePage())
                    };
                }
            }
        }
示例#17
0
        static void WorkWithWaitGames()
        {
            List <Game> waitGames = mysql.GetWaitGame(gameType);

            if (waitGames.Count > 0)
            {
                Helper.LOG("log.txt", $"Ожидающих сессий ({gameType}) - {waitGames.Count}");

                for (int i = 0; i < waitGames.Count; i++)
                {
                    try
                    {
                        Helper.LOG("log.txt", $"Работа с сессией №{waitGames[i].id}...");
                        mysql.SetGameWorkStatus(waitGames[i].id, gameType);
                        string[] temp_compiled_exe_path = new string[waitGames[i].usergroup.users.Count];

                        for (int j = 0; j < waitGames[i].usergroup.users.Count; j++)
                        {
                            dbUser tempUser = waitGames[i].usergroup.users[j];
                            tempUser.user_exe_phppath = $"{MyPath.binDir}\\{gameType}\\{waitGames[i].id}\\{tempUser.id}";
                        }

                        Session session = new Session(waitGames[i], $"{gameType}");

                        string json = OpenGameResultFile(waitGames[i].id);

                        if (gameType == "rating")
                        {
                            List <Player> users = JsonConvert.DeserializeObject <List <Player> >(json);

                            for (int k = 0; k < waitGames[i].usergroup.users.Count; k++)
                            {
                                var tempUser = waitGames[i].usergroup.users[k];

                                if (mysql.CheckUserIsBot(tempUser.id))
                                {
                                    continue;
                                }

                                for (int j = 0; j < users.Count; j++)
                                {
                                    if (int.Parse(users[j].ID) == tempUser.id)
                                    {
                                        mysql.AddUserRatingPoints(tempUser.id, users[j].Points);
                                        break;
                                    }
                                }
                            }
                        }
                        if (gameType == "final")
                        {
                            List <Player> users = JsonConvert.DeserializeObject <List <Player> >(json);

                            for (int k = 0; k < waitGames[i].usergroup.users.Count; k++)
                            {
                                var tempUser = waitGames[i].usergroup.users[k];

                                for (int j = 0; j < users.Count; j++)
                                {
                                    if (int.Parse(users[j].ID) == tempUser.id)
                                    {
                                        mysql.AddUserFinalPoints(tempUser.id, users[j].Points);
                                        break;
                                    }
                                }
                            }
                        }



                        mysql.SetGameCompiledStatus(waitGames[i].id, gameType, json);
                        Helper.LOG("log.txt", $"Игровая сессия ({gameType}) № {waitGames[i].id} успешно завершена!");
                    }
                    catch (Exception e)
                    {
                        Helper.LOG("log.txt", $"При работе игровой сессии ({gameType}) №{waitGames[i].id} возникла Ошибка: {e.Message}");
                        mysql.SetGameErrorStatus(waitGames[i].id, gameType, $"Ошибка при работе сессии: {e.Message}");
                    }
                }
            }
        }
示例#18
0
 public Task <int> SaveUser(dbUser user)
 {
     return(database.InsertAsync(user));
 }