Пример #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);

            IModel model = new User();
            IMainControllerView mainForm = new MainControllerForm();
            Presenter<IMainControllerView> presenter = new MainControllerPresenter(mainForm, model);

            Application.Run((Form)mainForm);
        }
Пример #2
0
        public static User Add(string connId, string username, string password, string category, string domain, string systemUsername, string ip, string mac, string cultureName)
        {
            var us = new User()
            {
                ConnectionId = connId,
                Domain = domain,
                Category = category,
                Username = username.ToLower(),
                Password = password,
                SystemUsername = systemUsername,
                EntryTime = DateTime.Now,
                IP = ip,
                MAC = mac,
                Culture = cultureName
            };

            Users.Add(connId, us);

            return us;
        }
Пример #3
0
        public static User FromIUser(IUser iUser)
        {
            if (iUser == null) return null;

            User user = new User();
            foreach (var prop in typeof(IUser).GetProperties())
            {
                var userProp = typeof(User).GetProperty(prop.Name);
                userProp.SetValue(user, prop.GetValue(iUser));
            }

            return user;
        }
Пример #4
0
        public async Task<bool> UsernameVerificationAsync(User user)
        {
            if (User.ContainsUsername(user.Username)) // this user already is exist
            {
                WindowsEventLog.WriteFailureAuditLog(
                    Properties.Resources.M0001.Replace("#username", user.Username).Replace("#IP", user.IP) +
                    Environment.NewLine, 1);

                await
                    CallCallerClientAsync("OnRaiseLog",
                        Properties.Resources.ResourceManager.GetString("M0001",
                            CultureInfo.CreateSpecificCulture(user.Culture)));

                return false;
            }
            else
            {
                user.ConnectionId = Context.ConnectionId;
                User.Add(user);
                await
                    Groups.Add(Context.ConnectionId, string.IsNullOrEmpty(user.Category) ? "Undefined" : user.Category);
                WindowsEventLog.WriteSuccessAuditLog(
                    Properties.Resources.M0002.Replace("#username", user.Username).Replace("#IP", user.IP) +
                    Environment.NewLine, 2);
                return true;
            }
        }