Exemplo n.º 1
0
        public ViewResult EditUser(UserInfoBase userinfo)
        {
            using (var context = new WebsiteDBEntities())
            {
                try
                {
                    var currentUser = context.UserInfoes.SingleOrDefault(i => i.UserName == userinfo.UserName);
                    if (currentUser != null)
                    {
                        if (userinfo.ResetPassword)
                        {
                            ChangePassWord(currentUser, userinfo.NewPassword, userinfo.NewPassword2);
                        }

                        currentUser.IsActive             = userinfo.IsActive;
                        currentUser.FullName             = userinfo.FullName;
                        context.Entry(currentUser).State = EntityState.Modified;
                        context.SaveChanges();
                        ViewBag.SaveMessage    = "Thông tin đã được lưu thành công";
                        userinfo.ResetPassword = false;
                    }
                    else
                    {
                        ViewBag.SaveMessage = string.Format("Không tìm thấy tài khoản tài khoản tên [{0}]. Yêu cầu quay lại trang danh sách và thử lại.", userinfo.UserName);
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.SaveMessage = ex.Message;
                }
                return(View(userinfo));
            }
        }
Exemplo n.º 2
0
 public UserWindow(MainWindow parent, UserInfoBase user) : this(parent)
 {
     this.ctrl_name.Text         = user.Name;
     this.ctrl_password.Password = user.Password;
     AreaName = user.AreaName;
     this.id  = user.ID;
     this.ctrl_role.SelectedIndex = user.RoleIndex;
 }
Exemplo n.º 3
0
        void InitRemoteProvider(UserInfoBase user)
        {
            var uuid = Guid.NewGuid().ToString();

            remoteService = new RemoteService(uuid, "client");
            remoteService.remoteProvider.OnReceivedMsg += RemoteProvider_OnReceivedMsg;
            serverProvider.SendMsg("client-init", user.GameHwnd, uuid);
        }
Exemplo n.º 4
0
 public GameOperation(UserInfoBase user)
 {
     this.user = user;
     fuhun     = new Fuhun(this);
     fight     = new Fight(this);
     kuafuBoss = new KuafuBoss(this);
     if (!Directory.Exists(folder_capture))
     {
         Directory.CreateDirectory(folder_capture);
     }
 }
Exemplo n.º 5
0
 public GameHandler(WebBrowser wb, UserInfoBase user, OneServiceRemoteProvider serverProvider)
 {
     this.wb             = wb;
     this.user           = user;
     this.serverProvider = serverProvider;
     gop = new GameOperation(user);
     wb.DocumentCompleted += wb_DocumentCompleted;
     //wb.Url = new Uri(user.AreaValue);
     wb.Url = new Uri(user.AreaValue);
     //ShowInTaskbar = false;
     gop.StateChange += Gop_OnStateChange;
     gop.DataEvent   += Gop_DataEvent;
 }
Exemplo n.º 6
0
 public void addUser(UserInfoBase user)
 {
     if (!String.IsNullOrEmpty(user.ID))
     {
         var column = this.Columns.First(item => item.ID == user.ID);
         column.Assign(user);
     }
     else
     {
         Columns.Add(new UserInfo(user));
     }
     this.RefreshTable();
     this.saveConfig();
 }
Exemplo n.º 7
0
        public ActionResult ChangePassword(UserInfoBase user, string currentPassword)
        {
            using (var context = new WebsiteDBEntities())
            {
                try
                {
                    var currentuser = context.UserInfoes.SingleOrDefault(i => i.UserName == user.UserName && i.IsActive);
                    if (currentuser == null)
                    {
                        throw new Exception(
                                  "Tài khoản của bạn đã bị khoá hoặc xoá. Liên hệ quản lý của bạn để được giúp đỡ.");
                    }

                    var crypto = new Hash {
                        Salt = currentuser.UserCode
                    };
                    var currentPass = crypto.Encrypt(currentPassword);

                    if (currentPass != currentuser.PassCode)
                    {
                        throw new Exception("Mật khẩu hiện tại không đúng.");
                    }

                    if (user.NewPassword != user.NewPassword2)
                    {
                        throw new Exception("Mật khẩu và xác nhận mật khẩu không khớp");
                    }
                    if (user.NewPassword.Length < 6)
                    {
                        throw new Exception("Mật khẩu phải chứa ít nhất 6 ký tự");
                    }

                    currentuser.PassCode             = crypto.Encrypt(user.NewPassword);
                    context.Entry(currentuser).State = EntityState.Modified;
                    context.SaveChanges();
                    user.ResetPassword = false;
                    Session[SiteConfig.TransferMessageSession] = "Mật khẩu đã đổi thành công";
                }
                catch (Exception ex)
                {
                    Session[SiteConfig.TransferMessageSession] = string.Format("Lỗi: {0}", ex.Message);
                }
                return(RedirectToAction("SiteMessage", new { id = 1 }));
            }
        }
Exemplo n.º 8
0
 public ActionResult EditUser(string userName)
 {
     using (var context = new WebsiteDBEntities())
     {
         var user = context.UserInfoes.SingleOrDefault(i => i.UserName == userName);
         if (user == null)
         {
             HttpContext.Session[SiteConfig.TransferMessageSession] = string.Format("Không tìm thấy tài khoản tên {0}.", userName);
             return(RedirectToAction("Users"));
         }
         var userinfo = new UserInfoBase
         {
             UserName      = user.UserName,
             FullName      = user.FullName,
             IsActive      = user.IsActive,
             ResetPassword = false
         };
         return(View(userinfo));
     }
 }
Exemplo n.º 9
0
        public GameWindow(OneServiceRemoteProvider serverProvider, UserInfoBase user) : this()
        {
#if !DEBUG
            SuppressWininetBehavior();
#endif
            this.serverProvider = serverProvider;
            this.FormClosing   += Form1_FormClosing;
            //serverProvider.SendMsg(ServiceRemoteType.InitClient, guid);
            InitRemoteProvider(user);
            AddPage(user);
            //AddPage(user);
            this.Text = user.Nickname + "-" + user.Name;

            //var tabpage = new TabPage("user.Nickname");
            //var wb = new WebBrowser();
            //wb.Dock = DockStyle.Fill;
            //tabpage.Controls.Add(wb);
            ////wb.Url = new Uri("http://frmmo.wan.360.cn/game_login.php?server_id=S2&src=360wan-2jxx-frmmo");
            //wb.Url = new Uri(user.AreaValue);
            //wb.ScriptErrorsSuppressed = true;
            //tab.TabPages.Add(tabpage);
        }
Exemplo n.º 10
0
        void AddPage(UserInfoBase user)
        {
            var tabpage = new TabPage(user.Nickname + "-" + user.Name);
            var wb      = new WebBrowser();

            wb.Dock = DockStyle.Fill;
            tabpage.Controls.Add(wb);
            //wb.Url = new Uri("http://frmmo.wan.360.cn/game_login.php?server_id=S2&src=360wan-2jxx-frmmo");
            wb.Url = new Uri(user.AreaValue);
            wb.ScriptErrorsSuppressed = true;
            tab.TabPages.Add(tabpage);

            var externaljs = new ExternalJS();

            //externaljs.OnReceived += Externaljs_OnReceived;
            wb.ObjectForScripting = externaljs;
            externaljs.OnLogined += Externaljs_OnLogined;
            tab.SelectedIndex     = tab.TabPages.Count - 1;

            var handler = new GameHandler(wb, user, serverProvider);

            handlers.Add(handler);
        }
Exemplo n.º 11
0
        void openGame(UserInfoBase user)
        {
            //if (clientProvider != null)
            //{
            //    clientProvider.SendMsg("new-user", user.GameHwnd, JsonConvert.SerializeObject(user));
            //    return;
            //}
            var user_str = HttpUtility.UrlEncode(JsonConvert.SerializeObject(user));

#if DEBUG
            File.WriteAllText("a.txt", String.Format("{0} {1}", remote_name, user_str));
            //return;
#endif
            //MessageBox.Show(String.Format("{0} {1}", remote_name, user_str));
            Process.Start(
                //Process.GetCurrentProcess().MainModule.FileName,
#if DEBUG
                @"E:\Users\Administrator\source\repos\WpfApp1\GameWindow\bin\Debug\GameWindow.exe",
#else
                @"GameWindow.exe",
#endif
                string.Format("{0} {1}", remote_name, user_str)
                );
        }
Exemplo n.º 12
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, UserInfoBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_GetUserInfo, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Google.Protobuf.WellKnownTypes.Empty, global::Userinfo.UserInfoResponse>(serviceImpl.GetUserInfo));
 }
Exemplo n.º 13
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(UserInfoBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_GetUserInfo, serviceImpl.GetUserInfo).Build());
 }
Exemplo n.º 14
0
 public UserInfo(UserInfoBase user) : base(user)
 {
 }