コード例 #1
0
ファイル: User.cs プロジェクト: radtek/credit-card-exchange
        /// <summary>
        /// Update the User based on an EntityRow.
        /// </summary>
        /// <param name="entityRow">The row to update from.</param>
        public override void Update(EntityRow entityRow)
        {
            UserRow userRow = DataModel.User.UserKey.Find(entityRow.EntityId);

            base.Update(entityRow);

            if (userRow != null)
            {
                if (!this.Modified && entityRow.EntityId == this.EntityId)
                {
                    this.IdentityName = userRow.IdentityName;
                    this.isRemoved    = userRow.IsRemoved;

                    this.groups.Clear();
                    foreach (GroupUsersRow groupRow in userRow.GetGroupUsersRows())
                    {
                        this.groups.Add(Entity.New(groupRow.GroupRow.RightsHolderRow.EntityRow) as Group);
                    }

                    // The information kept in AD takes a really long time to come back, so we'll grab it in another thread.
                    ThreadPoolHelper.QueueUserWorkItem(data => this.LoadAdInformation(data as String), this.IdentityName);
                }

                this.rowVersion = userRow.RowVersion;
            }
        }
コード例 #2
0
        /// <summary>
        /// Filter what rows are included in the list based on the value of includeRemovedUsers.
        /// </summary>
        /// <param name="row">The row to examine.</param>
        /// <returns>False if includeRemovedUsers is false and the user has been removed; true otherwise.</returns>
        protected override bool Filter(DataRow row)
        {
            UserRow userRow = null;
            Boolean include;

            if (row is UserRow)
            {
                userRow = row as UserRow;
            }
            else if (row is RightsHolderRow && this.Any(r => r.EntityId == (row as RightsHolderRow).RightsHolderId))
            {
                userRow = (row as RightsHolderRow).GetUserRows()[0];
            }
            else if (row is EntityRow && this.Any(r => r.EntityId == (row as EntityRow).EntityId))
            {
                userRow = (row as EntityRow).GetRightsHolderRows()[0].GetUserRows()[0];
            }
            else
            {
                throw new RowNotHandledException("row isn't the right kind of row");
            }

            include = (this.IncludeRemovedUsers || !userRow.IsRemoved) &&
                      (this.Tenant == null || (this.Tenant.Value == userRow.RightsHolderRow.TenantId));

            return(include);
        }
コード例 #3
0
        public async Task <ActionResult <User> > Get(int userId, bool includeInvoices)
        {
            if (userId <= 0)
            {
                return(UnprocessableEntity());
            }

            UserRow userRow = await _usersStorage.GetUserByIdAsync(userId);

            if (userRow == null)
            {
                return(NotFound());
            }
            User user = userRow.Convert();

            user.Address = (await _usersStorage.GetAddressByUserIdAsync(userId)).Convert();

            if (!includeInvoices)
            {
                return(user);
            }
            user.Invoices = (await _invoices.GetInvoicesByUserIdAsync(userId)).Convert(userId);

            return(user);
        }
コード例 #4
0
        /// <summary>
        /// Determine whether a rights holder has particular rights on an entity.
        /// </summary>
        /// <param name="rightsHolderRow">The rights holder</param>
        /// <param name="entity">The entity.</param>
        /// <param name="right">The required rights.</param>
        /// <returns>True if the rights holder has the specified rights to the entity.</returns>
        public static Boolean HasAccess(RightsHolderRow rightsHolderRow, EntityRow entity, AccessRight right)
        {
            // TODO: Remove this method? Current there are no calls to this method.
            // NOTE: This must be used in a background thread.

            Boolean grantedAccess = false;

            lock (DataModel.SyncRoot)
            {
                UserRow userRow = DataModel.User.UserKey.Find(rightsHolderRow.RightsHolderId);

                // See if the rights holder themself has access.
                foreach (AccessControlRow accessControlRow in rightsHolderRow.GetAccessControlRows())
                {
                    if (accessControlRow.EntityId == entity.EntityId &&
                        (accessControlRow.AccessRightRow.AccessRightCode & right) == right)
                    {
                        grantedAccess = true;
                    }
                }

                if (userRow != null)
                {
                    foreach (GroupUsersRow groupUsersRow in userRow.GetGroupUsersRows())
                    {
                        if (AccessControl.HasAccess(groupUsersRow.GroupRow.RightsHolderRow, entity, right))
                        {
                            grantedAccess = true;
                        }
                    }
                }
            }

            return(grantedAccess);
        }
コード例 #5
0
        public void ReplaceQueryPlaceHolder(QueryClass paQueryClass)
        {
            UserRow lcUserRow;

            if (paQueryClass != null)
            {
                if (ApplicationFrame.GetInstance().ActiveSessionController.User.IsLoggedIn)
                {
                    paQueryClass.ReplacePlaceHolder("$USERID", ApplicationFrame.GetInstance().ActiveSessionController.User.ActiveRow.UserID.ToString(), true);
                }

                paQueryClass.ReplaceRowPlaceHolder(ApplicationFrame.GetInstance().ActiveSubscription.ActiveRow.Row);
                paQueryClass.ReplaceRowPlaceHolder(ApplicationFrame.GetInstance().ActiveEservice.ActiveRow.Row);

                if ((lcUserRow = ApplicationFrame.GetInstance().ActiveSessionController.User.ActiveRow) == null)
                {
                    lcUserRow = new UserRow(TableManager.GetInstance().GetNewRow(TableManager.TableType.User, true));
                }

                paQueryClass.ReplaceRowPlaceHolder(lcUserRow.Row);

                paQueryClass.ReplacePlaceHolder("$ACTIVELANGUAGE", ApplicationFrame.GetInstance().ActiveSubscription.ActiveSetting.Language, true);

                paQueryClass.ReplaceDictionaryPlaceHolder(clFormParam, false);
            }
        }
コード例 #6
0
ファイル: Misc.cs プロジェクト: tjcomserv/SuperGrate
 /// <summary>
 /// Retrieves users from the Backup Store in a UserRows object. (UserRows are based off of the ULControl.CurrentHeaderRow property.)
 /// </summary>
 /// <returns>A UserRow object.</returns>
 static public Task <UserRows> GetUsersFromStore()
 {
     return(Task.Run(async() =>
     {
         try
         {
             string StorePath = Config.Settings["MigrationStorePath"];
             Logger.Information("Listing users from store: " + StorePath + "...");
             UserRows rows = new UserRows();
             int count = 0;
             DirectoryInfo[] directories = new DirectoryInfo(StorePath).GetDirectories();
             foreach (DirectoryInfo directory in directories)
             {
                 UserRow row = await GetUserFromStore(ULControl.CurrentHeaderRow, directory.Name);
                 if (row == null)
                 {
                     Logger.Warning("Skipping ID: " + directory.Name);
                     continue;
                 }
                 rows.Add(row);
                 Logger.UpdateProgress((int)(((float)++count / directories.Length) * 100));
                 Logger.Verbose("Found: " + row[ULColumnType.NTAccount]);
             }
             Logger.Success("Users listed successfully.");
             return rows;
         }
         catch (Exception e)
         {
             Logger.Exception(e, "Failed to list users from store.");
             return null;
         }
     }));
 }
コード例 #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            UserRow objUser = Profile.GetUserInfo(user_id);

            if (txtCurrentPassword.Text.Trim() != "")
            {
                string md5_pass = FormsAuthentication.HashPasswordForStoringInConfigFile(txtCurrentPassword.Text.Trim(), "MD5");
                if (txtPassword.Text.Trim() != txtPasswordAgian.Text.Trim())
                {
                    ltrMessage.Text = "<font color=red>Gõ lại mật khẩu !</font>";
                    return;
                }

                if (md5_pass != objUser.User_Pwd)
                {
                    ltrMessage.Text = "<font color=red>Mật khẩu hiện thời không đúng !</font>";
                    return;
                }

                if (FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(), "MD5") == objUser.User_Pwd)
                {
                    ltrMessage.Text = "<font color=red>Mật khẩu mới không được trùng với mật khẩu cũ!</font>";
                    return;
                }
            }

            objsoure.Update();
            ltrMessage.Text = "<font color=red>Lưu lại thành công</font>";
        }
コード例 #8
0
        private async Task CreateNewUsers(List <Friend> remoteFriends)
        {
            foreach (var friend in remoteFriends)
            {
                if (string.IsNullOrEmpty(friend.Email) || await _userService.UserExists(friend.Email))
                {
                    continue;
                }

                var user = new UserRow
                {
                    Identifier    = Guid.NewGuid(),
                    Username      = friend.Username,
                    Email         = friend.Email,
                    PlexAccountId = Convert.ToInt32(friend.Id),
                    UserRoles     = new List <UserRoleRow>
                    {
                        new UserRoleRow
                        {
                            Role = PlexRequestRoles.User
                        },
                        new UserRoleRow
                        {
                            Role = PlexRequestRoles.Commenter
                        }
                    }
                };

                await _userService.AddUser(user);
            }
        }
コード例 #9
0
ファイル: Main.cs プロジェクト: tjcomserv/SuperGrate
 /// <summary>
 /// This event will open the User Properties dialog box.
 /// </summary>
 private async void OpenUserProperties_Event(object sender, EventArgs e)
 {
     if (listUsers.SelectedItems.Count == 1)
     {
         Running = RunningTask.Unknown;
         Logger.Information("Retrieving user properties...");
         UserRow row      = null;
         UserRow template = null;
         if (CurrentListSource == ListSources.MigrationStore)
         {
             template = ULControl.HeaderRowStoreSource;
             row      = await Misc.GetUserFromStore(template, (string)listUsers.SelectedItems[0].Tag);
         }
         if (CurrentListSource == ListSources.SourceComputer)
         {
             template = ULControl.HeaderRowComputerSource;
             row      = await Misc.GetUserFromHost(template, tbSourceComputer.Text, (string)listUsers.SelectedItems[0].Tag);
         }
         if (Canceled)
         {
             Running = RunningTask.None;
             Logger.Information("Canceled.");
             return;
         }
         Running = RunningTask.None;
         Logger.Success("Done!");
         new UserProperties(template, row).ShowDialog();
     }
 }
コード例 #10
0
        public WidControlPOSChangePassword()
        {
            clUserRow = RetrieveRow();

            clLanguageManager = ApplicationFrame.GetInstance().ActiveSubscription.ActiveLanguage;
            clSettingManager  = ApplicationFrame.GetInstance().ActiveSubscription.ActiveSetting;
        }
コード例 #11
0
        public static String CompileShortAddress(DataRow paDataRow)
        {
            UserRow             lcUserRow;
            String              lcBuildingNo;
            String              lcFloor;
            String              lcStreet;
            String              lcCompiledString;
            
            lcUserRow           = new UserRow(paDataRow);
            lcBuildingNo        = lcUserRow.BuildingNo.Trim();
            lcFloor             = lcUserRow.Floor.Trim();
            lcStreet            = lcUserRow.Street.Trim();
            
            if (lcFloor.Length > 0) 
            {
                lcBuildingNo = ctBuildingNoPrefix + " " + lcBuildingNo + ctMinorSeparator;
                if (lcFloor.Length < 2) lcFloor = lcFloor + " " + ctMiniFloorSuffix + ctMinorSeparator;
                else lcFloor = lcFloor + " " + ctFloorSuffix + ctMinorSeparator;
            }
            else lcBuildingNo = ctHomeNoPrefix + " " + lcBuildingNo + ctMinorSeparator;
            
            if (lcStreet.Length > 0) lcStreet = lcStreet + " " + ctStreetSuffix + ctMinorSeparator;

            lcCompiledString = lcBuildingNo + lcStreet;

            return (lcCompiledString);
        }
コード例 #12
0
        protected override bool OnViewSubmit()
        {
            var request = new ServiceRequest();

            Q.ServiceCall(new ServiceCallOptions
            {
                Url = Q.ResolveUrl("~/Administration/User/getUser"),

                Request   = request.As <ServiceRequest>(),
                OnSuccess = response =>
                {
                    dynamic obj = response;
                    UserRow t   = (UserRow)obj;
                    user_name   = t.Username;
                    admin_lv    = obj.adminlv;
                    if (i_refresh == 1)
                    {
                        i_refresh = 0;
                        Refresh();
                    }
                }
            });

            var req = (ListRequest)view.Params;

            req.EqualityFilter = req.EqualityFilter ?? new JsDictionary <string, object>();
            //if (admin_lv == "1")
            //    req.EqualityFilter["By_User"] = "";
            //else
            //    req.EqualityFilter["By_User"] = user_name;
            req.EqualityFilter["Submit"] = "1";
            return(true);
        }
コード例 #13
0
        public string CreateToken(UserRow user)
        {
            var tokenHandler = new JwtSecurityTokenHandler();
            var secretKey    = Encoding.ASCII.GetBytes(_authSettings.SecretKey);
            var claims       = new List <Claim>
            {
                new Claim(ClaimTypes.Name, user.Username),
                new Claim(JwtRegisteredClaimNames.Sub, user.UserId.ToString()),
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N"))
            };

            foreach (var userRole in user.UserRoles)
            {
                claims.Add(new Claim(ClaimTypes.Role, userRole.Role));
            }

            var expiry = DateTime.UtcNow.AddMinutes(_authSettings.TokenExpirationMinutes);

            //Remove milliseconds from the time as it gets stripped when the token is serialised
            expiry = expiry.AddMilliseconds(-expiry.Millisecond);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject            = new ClaimsIdentity(claims),
                Expires            = expiry,
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(secretKey), SecurityAlgorithms.HmacSha256Signature),
                Audience           = _authSettings.Audience,
                Issuer             = _authSettings.Issuer
            };

            user.InvalidateTokensBeforeUtc = expiry;

            var token = tokenHandler.CreateToken(tokenDescriptor);

            return(tokenHandler.WriteToken(token));
        }
コード例 #14
0
        public async Task <IEnumerable <BetRow> > GetUserGameHistory(int userId, int?pageNumber, int?itemsPerPage)
        {
            var skip = pageNumber == null ? 0 : (pageNumber - 1) * itemsPerPage;
            var take = itemsPerPage == null ? 15 : itemsPerPage;

            string userQuery = "SELECT Id FROM Users WHERE Id = @userId";

            string betQuery = "SELECT SpinID, BetAmount, CreateDate, WonAmount FROM Bets WHERE UserId = @userId ORDER BY CreateDate DESC LIMIT @skip, @take";

            UserRow user = null;
            IEnumerable <BetRow> bets = null;

            using (var db = _dbProvider.GetDBInstance())
            {
                db.Open();

                user = await db.QueryFirstOrDefaultAsync <UserRow>(userQuery, new { userId });

                if (user != null)
                {
                    bets = await db.QueryAsync <BetRow>(betQuery, new { userId, skip, take });
                }

                db.Close();
            }

            return(bets);
        }
コード例 #15
0
        private async Task <UserRow> AddAdminUser(User plexUser, UserRefreshTokenRow refreshToken)
        {
            var adminUser = new UserRow
            {
                Identifier    = Guid.NewGuid(),
                Username      = plexUser.Username,
                Email         = plexUser.Email,
                PlexAccountId = plexUser.Id,
                IsAdmin       = true,
                UserRoles     = new List <UserRoleRow>
                {
                    new UserRoleRow
                    {
                        Role = PlexRequestRoles.Admin
                    },
                    new UserRoleRow
                    {
                        Role = PlexRequestRoles.User
                    },
                    new UserRoleRow
                    {
                        Role = PlexRequestRoles.Commenter
                    }
                },
                UserRefreshTokens = new List <UserRefreshTokenRow> {
                    refreshToken
                }
            };

            _logger.LogInformation("Creating Admin account");
            await _userService.AddUser(adminUser);

            return(adminUser);
        }
コード例 #16
0
ファイル: Main.cs プロジェクト: tjcomserv/SuperGrate
        /// <summary>
        /// This event fires when the miAddRemoveCol menu item is clicked, and will display the column selection dialog box.
        /// </summary>
        private void miAddRemoveCol_Click(object sender, EventArgs e)
        {
            string  SettingKey          = "";
            UserRow AllAvailableColumns = null;

            if (CurrentListSource == ListSources.MigrationStore)
            {
                SettingKey          = "ULStoreColumns";
                AllAvailableColumns = ULControl.HeaderRowStoreSource;
            }
            else if (CurrentListSource == ListSources.SourceComputer)
            {
                SettingKey          = "ULSourceColumns";
                AllAvailableColumns = ULControl.HeaderRowComputerSource;
            }
            else
            {
                return;
            }
            ChangeColumns ColDialog = new ChangeColumns();
            Dictionary <string, object> AvailableColumns = new Dictionary <string, object>();
            Dictionary <string, object> DisplayedColumns = new Dictionary <string, object>();

            foreach (KeyValuePair <ULColumnType, string> Column in AllAvailableColumns)
            {
                if (!ULControl.CurrentHeaderRow.ContainsKey(Column.Key))
                {
                    AvailableColumns.Add(Column.Value, Column.Key);
                }
            }
            foreach (KeyValuePair <ULColumnType, string> Column in ULControl.CurrentHeaderRow)
            {
                if (Column.Value != null)
                {
                    DisplayedColumns.Add(Column.Value, Column.Key);
                }
            }
            ColDialog.AvailableColumns = AvailableColumns;
            ColDialog.DisplayedColumns = DisplayedColumns;
            DialogResult result = ColDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string Setting = "";
                foreach (ULColumnType Column in ColDialog.DisplayedColumns.Values)
                {
                    Setting += ((int)Column).ToString() + ',';
                }
                Config.Settings[SettingKey] = Setting.TrimEnd(',');
                if (CurrentListSource == ListSources.MigrationStore)
                {
                    btnListStore.PerformClick();
                }
                if (CurrentListSource == ListSources.SourceComputer)
                {
                    btnListSource.PerformClick();
                }
            }
        }
コード例 #17
0
        private WinUser Serialize(UserRow userRow)
        {
            WinUser user = new WinUser();

            user.Name           = userRow.Username;
            user.SID            = userRow.SID;
            user.FullName       = userRow.Fullname;
            user.Identification = "Password OR Biometrics";
            return(user);
        }
コード例 #18
0
        private async Task UpdateUser(UpdateUserCommand command, UserRow user)
        {
            user.IsDisabled = command.IsDisabled;
            user.UserRoles  = command.Roles.Select(newRole => new UserRoleRow
            {
                Role = newRole
            }).ToList();

            await _unitOfWork.CommitAsync();
        }
コード例 #19
0
            public UserRow AddUserRow(string Username)
            {
                UserRow rowUserRow = ((UserRow)(this.NewRow()));

                rowUserRow.ItemArray = new object[] {
                    Username
                };
                this.Rows.Add(rowUserRow);
                return(rowUserRow);
            }
コード例 #20
0
        /// <summary>
        /// Grant a particular rights holder specific rights to an entity.
        /// </summary>
        /// <param name="rightsHolderId">The rights holder's id.</param>
        /// <param name="entityId">The entity's id.</param>
        /// <param name="rightId">The specific right's id.</param>
        /// <returns>The id of the AccessControl row.</returns>
        internal static Guid GrantAccess(Guid rightsHolderId, Guid entityId, Guid rightId)
        {
            DataModelTransaction transaction = DataModelTransaction.Current;
            DataModel            dataModel   = new DataModel();
            Guid             currentUserId   = TradingSupport.UserId;
            UserRow          currentUserRow  = DataModel.User.UserKey.Find(currentUserId);
            RightsHolderRow  rightsHolderRow = DataModel.RightsHolder.RightsHolderKey.Find(rightsHolderId);
            Guid             rightsHolderTenantId;
            AccessControlRow accessControlRow = DataModel.AccessControl.AccessControlKeyRightsHolderIdEntityId.Find(rightsHolderId, entityId);
            Guid             accessControlId  = Guid.Empty;

            // Determine whether current user has write access to the entity.
            if (!DataModelFilters.HasAccess(transaction, currentUserId, entityId, AccessRight.Write))
            {
                throw new FaultException <SecurityFault>(
                          new SecurityFault(String.Format("{0} does not write permission to {1}", rightsHolderId, entityId)));
            }

            rightsHolderRow.AcquireReaderLock(transaction);
            rightsHolderTenantId = rightsHolderRow.TenantId;
            rightsHolderRow.ReleaseReaderLock(transaction.TransactionId);

            // Determine whether current user's tenant is upstream from rights holder we're modifying.
            if (!DataModelFilters.HasTenantAccess(transaction, currentUserId, rightsHolderTenantId))
            {
                throw new FaultException <SecurityFault>(
                          new SecurityFault(String.Format("{0} does not control over tenant {1}", rightsHolderId, rightsHolderTenantId)));
            }

            if (accessControlRow != null)
            {
                accessControlRow.AcquireWriterLock(transaction);
                accessControlId = accessControlRow.AccessControlId;
                dataModel.UpdateAccessControl(
                    accessControlRow.AccessControlId,
                    new object[] { accessControlRow.AccessControlId },
                    rightId,
                    entityId,
                    rightsHolderId,
                    accessControlRow.RowVersion,
                    rightsHolderTenantId);
            }
            else
            {
                accessControlId = Guid.NewGuid();
                dataModel.CreateAccessControl(
                    accessControlId,
                    rightId,
                    entityId,
                    rightsHolderId,
                    rightsHolderTenantId);
            }

            return(accessControlId);
        }
コード例 #21
0
ファイル: Misc.cs プロジェクト: tjcomserv/SuperGrate
 /// <summary>
 /// Retrieves users' properties from host based on the ULControl.CurrentHeaderRow property.
 /// </summary>
 /// <param name="Host">Host to get information from.</param>
 /// <returns>UserRows.</returns>
 public static Task <UserRows> GetUsersFromHost(string Host)
 {
     return(Task.Run(async() =>
     {
         try
         {
             UserRows rows = new UserRows();
             RegistryKey remoteReg = null;
             if (IsHostThisMachine(Host))
             {
                 remoteReg = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default);
             }
             else
             {
                 remoteReg = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, Host);
             }
             RegistryKey profileList = remoteReg.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", false);
             Logger.Information("Getting list of users on: " + Host + "...");
             GetLocalUsersSIDsFromHost(Host);
             string[] SIDs = profileList.GetSubKeyNames();
             int count = 0;
             foreach (string SID in SIDs)
             {
                 if (Main.Canceled)
                 {
                     break;
                 }
                 UserRow row = await GetUserFromHost(ULControl.CurrentHeaderRow, Host, SID);
                 Logger.UpdateProgress((int)(((float)++count / SIDs.Length) * 100));
                 if (row != null)
                 {
                     rows.Add(row);
                 }
             }
             remoteReg.Close();
             if (Main.Canceled)
             {
                 Logger.Warning("Listing users was canceled.");
                 return null;
             }
             Logger.Success("Users listed successfully.");
             return rows;
         }
         catch (System.Security.SecurityException e)
         {
             Logger.Exception(e, "Failed to get a list of users. Please make sure the user \"" + Environment.UserDomainName + "\\" + Environment.UserName + "\" is an administrator on the host: " + Host);
             return null;
         }
         catch (Exception e)
         {
             Logger.Exception(e, "Failed to get a list of users. Please make sure that the specified host is valid and online, also make sure the \"Remote Registry\" service is enabled and running on the specified host: " + Host);
             return null;
         }
     }));
 }
コード例 #22
0
            public UserRoleRow AddUserRoleRow(RoleRow parentRoleRowByRoleUserRole, UserRow parentUserRowByUser_UserRole)
            {
                UserRoleRow rowUserRoleRow = ((UserRoleRow)(this.NewRow()));

                rowUserRoleRow.ItemArray = new object[] {
                    parentRoleRowByRoleUserRole[0],
                    parentUserRowByUser_UserRole[0]
                };
                this.Rows.Add(rowUserRoleRow);
                return(rowUserRoleRow);
            }
コード例 #23
0
ファイル: ArtooBase.cs プロジェクト: ndabas/Artoo
        public BuddyRow AddBuddyRow(string id, UserRow parentUserRowByUser_Buddy)
        {
            BuddyRow rowBuddyRow = ((BuddyRow)(this.NewRow()));

            rowBuddyRow.ItemArray = new object[] {
                id,
                parentUserRowByUser_Buddy[3]
            };
            this.Rows.Add(rowBuddyRow);
            return(rowBuddyRow);
        }
コード例 #24
0
ファイル: ArtooBase.cs プロジェクト: ndabas/Artoo
        public StatusRow AddStatusRow(int id, string StatusText, UserRow parentUserRowByUser_Status)
        {
            StatusRow rowStatusRow = ((StatusRow)(this.NewRow()));

            rowStatusRow.ItemArray = new object[] {
                id,
                StatusText,
                parentUserRowByUser_Status[3]
            };
            this.Rows.Add(rowStatusRow);
            return(rowStatusRow);
        }
コード例 #25
0
ファイル: User.cs プロジェクト: thientd87/XeVaPhongCach2018
 /// <summary>
 /// Kiểm tra xem có user này trong DB chưa
 /// </summary>
 /// <param name="userID">user ID</param>
 /// <returns>true nếu đã tồn tại</returns>
 public bool isUserExited(string userID)
 {
     using (MainDB db = new MainDB())
     {
         UserRow ur = db.UserCollection.GetByPrimaryKey(userID.Trim().ToLower());
         if (ur != null)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #26
0
            public UserRow AddUserRow(string login, string password, string firstName, string surName)
            {
                UserRow rowUserRow = ((UserRow)(this.NewRow()));

                rowUserRow.ItemArray = new object[] {
                    login,
                    password,
                    firstName,
                    surName
                };
                this.Rows.Add(rowUserRow);
                return(rowUserRow);
            }
コード例 #27
0
ファイル: ArtooBase.cs プロジェクト: ndabas/Artoo
        public UserRow AddUserRow(string id, int token, string password)
        {
            UserRow rowUserRow = ((UserRow)(this.NewRow()));

            rowUserRow.ItemArray = new object[] {
                id,
                token,
                password,
                null
            };
            this.Rows.Add(rowUserRow);
            return(rowUserRow);
        }
コード例 #28
0
        public async Task <UserListResponse> Login([FromBody] UserLoginRequest user)
        {
            UserListResponse userListResponse = new UserListResponse();

            if (ModelState.IsValid)
            {
                userListResponse.Users = new List <UserRow>();
                UserRow userRow      = new UserRow();
                var     existingUser = await _userManager.FindByNameAsync(user.UserName);

                if (existingUser == null)
                {
                    return(userListResponse.ToInvalidUserNameOrPassword <UserListResponse>());
                }

                var isCorrect = await _userManager.CheckPasswordAsync(existingUser, user.Password);

                if (isCorrect)
                {
                    Constants.LoginUserName = user.UserName;
                    var jwtToken = GenerateJwtToken(existingUser.Id);
                    userRow.Token = jwtToken;
                }
                else
                {
                    return(userListResponse.ToInvalidUserNameOrPassword <UserListResponse>());
                }

                var roles = _aspNetUserRolesService.getUserRolesByUserIdAsync(existingUser.Id);
                if (roles != null)
                {
                    userRow.Roles = new List <RoleRow>();
                    userRow.Roles = roles.Result.Roles;
                }
                var claim = _aspNetUserRolesService.getUserClaimsByUserIdAsync(existingUser.Id);
                if (claim != null)
                {
                    userRow.Claims = new List <ClaimsRow>();
                    userRow.Claims = claim.Result.Claims;
                }
                userRow.UserName = user.UserName;
                userRow.Id       = existingUser.Id;
                userRow.Email    = existingUser.Email;
                userListResponse.Users.Add(userRow);
                userListResponse.ToSuccess <UserListResponse>();


                return(userListResponse);
            }
            return(userListResponse.ToIncompleteInput <UserListResponse>());
        }
コード例 #29
0
 /// <summary>
 /// Kiểm tra trạng thái của user
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public bool IsUserActive(string userID)
 {
     using (MainDB db = new MainDB()) {
         UserRow ur = db.UserCollection.GetByPrimaryKey(userID.Trim());
         if (ur != null)
         {
             return(ur.User_isActive);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #30
0
 public static User ToModel(this UserRow userRow)
 {
     return(new User(
                userRow.UserId,
                userRow.Identifier,
                userRow.PlexAccountId,
                userRow.Username,
                userRow.Email,
                userRow.IsAdmin,
                userRow.IsDisabled,
                userRow.LastLoginUtc,
                userRow.InvalidateTokensBeforeUtc
                ));
 }
コード例 #31
0
ファイル: Phones.cs プロジェクト: dpaluy/SMS_Center
 public void RemoveUserRow(UserRow row)
 {
     this.Rows.Remove(row);
 }
コード例 #32
0
ファイル: Phones.cs プロジェクト: dpaluy/SMS_Center
 public void AddUserRow(UserRow row)
 {
     this.Rows.Add(row);
 }
コード例 #33
0
ファイル: VCFDataSet.cs プロジェクト: kathygns/citi-hust
 /// <summary>
 /// 注意同时要修改 Regex r = new Regex(@".+[(.+)]");
 /// </summary>
 /// <param name="u"></param>
 /// <returns></returns>
 public static string FormatUserName_RealName(UserRow u)
 {
     return u.RealName + "[" + u.UserName + "]";
 }
コード例 #34
0
 public ProjectRow AddProjectRow(string Name, string Discription, UserRow parentUserRowByFK_Project_Project, System.DateTime CreateDate, bool IsActive) {
     ProjectRow rowProjectRow = ((ProjectRow)(this.NewRow()));
     rowProjectRow.ItemArray = new object[] {
             null,
             Name,
             Discription,
             parentUserRowByFK_Project_Project[0],
             CreateDate,
             IsActive};
     this.Rows.Add(rowProjectRow);
     return rowProjectRow;
 }
コード例 #35
0
 public DistributionRow AddDistributionRow(UserRow parentUserRowByFK_Distribution_User, UserRow parentUserRowByFK_Distribution_User1, byte DistributionType, string Purpose, ProjectRow parentProjectRowByFK_Distribution_Project, System.DateTime DistributionDate, decimal Money, byte FeedbackStatus) {
     DistributionRow rowDistributionRow = ((DistributionRow)(this.NewRow()));
     rowDistributionRow.ItemArray = new object[] {
             null,
             parentUserRowByFK_Distribution_User[0],
             parentUserRowByFK_Distribution_User1[0],
             DistributionType,
             Purpose,
             parentProjectRowByFK_Distribution_Project[0],
             DistributionDate,
             Money,
             FeedbackStatus};
     this.Rows.Add(rowDistributionRow);
     return rowDistributionRow;
 }
コード例 #36
0
 public DonationRow AddDonationRow(UserRow parentUserRowByFK_Donation_User, string BankAccount, decimal Money, System.DateTime DonationDate, ProjectRow parentProjectRowByFK_Donation_Project) {
     DonationRow rowDonationRow = ((DonationRow)(this.NewRow()));
     rowDonationRow.ItemArray = new object[] {
             null,
             parentUserRowByFK_Donation_User[0],
             BankAccount,
             Money,
             DonationDate,
             parentProjectRowByFK_Donation_Project[0]};
     this.Rows.Add(rowDonationRow);
     return rowDonationRow;
 }
コード例 #37
0
 public UserRoleRow AddUserRoleRow(RoleRow parentRoleRowByRoleUserRole, UserRow parentUserRowByUser_UserRole) {
     UserRoleRow rowUserRoleRow = ((UserRoleRow)(this.NewRow()));
     object[] columnValuesArray = new object[] {
             null,
             null};
     if ((parentRoleRowByRoleUserRole != null)) {
         columnValuesArray[0] = parentRoleRowByRoleUserRole[0];
     }
     if ((parentUserRowByUser_UserRole != null)) {
         columnValuesArray[1] = parentUserRowByUser_UserRole[0];
     }
     rowUserRoleRow.ItemArray = columnValuesArray;
     this.Rows.Add(rowUserRoleRow);
     return rowUserRoleRow;
 }
コード例 #38
0
ファイル: Phones.cs プロジェクト: dpaluy/SMS_Center
 public UserRowChangeEvent(UserRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
コード例 #39
0
 public UserRow AddUserRow(
             string UserName, 
             string Password, 
             string SecureQuestion, 
             string SecureAnswer, 
             byte Role, 
             string Photo, 
             System.DateTime RegDate, 
             string RealName, 
             bool Sex, 
             byte Age, 
             string Tel, 
             string Email, 
             string Address, 
             string Comment, 
             string BankAccount, 
             string IdentityCard, 
             string Position, 
             UserRow parentUserRowByFK_User_User) {
     UserRow rowUserRow = ((UserRow)(this.NewRow()));
     rowUserRow.ItemArray = new object[] {
             null,
             UserName,
             Password,
             SecureQuestion,
             SecureAnswer,
             Role,
             Photo,
             RegDate,
             RealName,
             Sex,
             Age,
             Tel,
             Email,
             Address,
             Comment,
             BankAccount,
             IdentityCard,
             Position,
             parentUserRowByFK_User_User[0]};
     this.Rows.Add(rowUserRow);
     return rowUserRow;
 }
コード例 #40
0
 public UserRelationShipRow AddUserRelationShipRow(UserRow parentUserRowByFK_UserRelationShip_User, UserRow parentUserRowByFK_UserRelationShip_User1, ProjectRow parentProjectRowByFK_UserRelationShip_Project) {
     UserRelationShipRow rowUserRelationShipRow = ((UserRelationShipRow)(this.NewRow()));
     rowUserRelationShipRow.ItemArray = new object[] {
             parentUserRowByFK_UserRelationShip_User[0],
             parentUserRowByFK_UserRelationShip_User1[0],
             parentProjectRowByFK_UserRelationShip_Project[0]};
     this.Rows.Add(rowUserRelationShipRow);
     return rowUserRelationShipRow;
 }
コード例 #41
0
 public UserRowChangeEvent(UserRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
コード例 #42
0
 public UserRoleRow AddUserRoleRow(RoleRow parentRoleRowByRoleUserRole, UserRow parentUserRowByUser_UserRole)
 {
     UserRoleRow rowUserRoleRow = ((UserRoleRow)(this.NewRow()));
     rowUserRoleRow.ItemArray = new object[] {
             parentRoleRowByRoleUserRole[0],
             parentUserRowByUser_UserRole[0]};
     this.Rows.Add(rowUserRoleRow);
     return rowUserRoleRow;
 }