Example #1
0
        public void Insert(ref DBHelper dbInstance, IStateNews objNews, IImageDetail objImageDetail, IUsers user)
        {
            try
            {
                dbInstance.ClearAllParameters();
                dbInstance.AddInParameter("@EditorID", objNews.EditorID, DbType.String);
                dbInstance.AddInParameter("@DisplayOrder", objNews.DisplayOrder, DbType.Int32);
                dbInstance.AddInParameter("@Heading", objNews.Heading, DbType.String);
                dbInstance.AddInParameter("@ShortDescription", objNews.ShortDescription, DbType.String);
                dbInstance.AddInParameter("@NewsDescription", objNews.NewsDescription, DbType.String);
                dbInstance.AddInParameter("@LanguageID", objNews.LanguageID, DbType.Int32);
                dbInstance.AddInParameter("@StateCode", objNews.StateCode, DbType.String);
                dbInstance.AddInParameter("@IsTopNews", objNews.IsTopNews, DbType.Int32);
                dbInstance.AddInParameter("@ImageUrl", objImageDetail.ImageUrl, DbType.String);
                dbInstance.AddInParameter("@Caption", objImageDetail.Caption, DbType.String);
                dbInstance.AddInParameter("@CaptionLink", objImageDetail.CaptionLink, DbType.String);
                dbInstance.AddInParameter("@ImageType", objImageDetail.ImageType, DbType.Int32);
                dbInstance.AddInParameter("@IsFirst", objImageDetail.IsFirst, DbType.Int32);
                dbInstance.AddInParameter("@UserID", user.UserID, DbType.Int64);

                dbInstance.ExecuteNonQuery(ProcedureName.InsertStateNews, CommandType.StoredProcedure);
            }
            catch (Exception objExp)
            {
                throw objExp;
            }
        }
Example #2
0
 internal MailChimp(
     IAutomations automations, 
     ICampaigns campaigns, 
     IConversations conversations, 
     IEcomm ecomm, 
     IFolders folders, 
     IGallery gallery, 
     IGoal goal, 
     IHelper helper, 
     ILists lists, 
     IReports reports, 
     ITemplates templates, 
     IUsers users, 
     IVip vip)
 {
     Automations = automations;
     Campaigns = campaigns;
     Conversations = conversations;
     Ecomm = ecomm;
     Folders = folders;
     Gallery = gallery;
     Goal = goal;
     Helper = helper;
     Lists = lists;
     Reports = reports;
     Templates = templates;
     Users = users;
     Vip = vip;
 }
        public AccontModule(IUserController userController, IUsers users)
            : base("/Account")
        {
            this.userController = userController;
            this.users = users;
            this.RequiresAuthentication();

            Post["/"] = x =>
                            {
                                var user = this.Bind<User>();
                                var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);
                                if(user.Id == userId)
                                    this.userController.Update(user);
                                else
                                    return Response.AsJson(new []{false});
                                return Response.AsJson(new []{true});
                            };

            Get["/"] = x =>
                           {
                               var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);
                               var user = this.users.Get(userId);
                               return Response.AsJson(user);
                           };
        }
        public UsersModule(IUsers users, IPasswordGenerator passwordGenerator,
            IHashing hashing, IEmailGateway emailGateway, IEventLog eventLog)
            : base("/User")
        {
            this.users = users;
            this.passwordGenerator = passwordGenerator;
            this.hashing = hashing;
            this.emailGateway = emailGateway;
            this.eventLog = eventLog;

            Post["/"] = x =>
                            {
                                var email = Request.Query.email.ToString();

                                if (!string.IsNullOrEmpty(email))
                                {
                                    var fromDb = this.users.Get(email);
                                    if (fromDb != null)
                                        return Response.AsJson(new[] {fromDb});

                                    var password = this.users.Create(email);
                                    return Response.AsJson(new[] {new {password}});
                                }
                                return Response.AsJson(Enumerable.Empty<string>());
                            };

            Get["/PasswordReset"] = x =>
                                        {
                                            return View["passwordreset", new Result  { Success = false }];
                                        };

            Post["/PasswordReset"] = x =>
                                         {
                                             bool result = false;
                                             var input = this.Bind<PasswordResetBody>();
                                             if(!string.IsNullOrWhiteSpace(input.email))
                                             {
                                                 var user = this.users.Get(input.email);
                                                 if(user!= null)
                                                 {
                                                     var password = this.passwordGenerator.Generate();
                                                     var hashedPassword = this.hashing.Hash(password);
                                                     this.users.ChangePassword(user.Id, hashedPassword);
                                                     this.emailGateway.SendNewPasswordEmail(user.Email, password);
                                                     result = true;

                                                     this.eventLog.LogEvent(new Event()
                                                                                {
                                                                                    AuthorId = user.Id,
                                                                                    BarCodeId = null,
                                                                                    EventName = "CHANGEPASSWORD",
                                                                                    Ip = this.Request.Headers["X-Forwarded-For"].FirstOrDefault()
                                                                                });
                                                 }
                                             }

                                             return View["passwordreset", new Result { Success = result }];
                                         };
        }
Example #5
0
        public UserManager(ISecurityManager securityManager, IUsers userDataAccess)
        {
            if (securityManager == null) throw new ArgumentNullException("securityManager");
            if (userDataAccess == null) throw new ArgumentNullException("userDataAccess");

            _securityManager = securityManager;
            _userDataAccess = userDataAccess;
        }
Example #6
0
        public SecurityManager(IUsers userDataAccess, ICryptographyManager cryptographyManager, IUsers users)
        {
            if (userDataAccess == null) throw new ArgumentNullException("userDataAccess");
            if (cryptographyManager == null) throw new ArgumentNullException("cryptographyManager");
            if (users == null) throw new ArgumentNullException("users");

            _dataAccess = userDataAccess;
            _cryptographyManager = cryptographyManager;
            _users = users;
        }
Example #7
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     UsersRunTarget = new Mock<IUsersRunTarget>();
     Users = new PHmiClient.Users.Users(UsersRunTarget.Object);
     CurrentPropertyChangedCount = 0;
     Users.PropertyChanged += (sender, args) =>
         {
             if (args.PropertyName == "Current")
                 CurrentPropertyChangedCount++;
         };
 }
Example #8
0
        public async Task<bool> IsValidUser(IUsers userDetail, string EmailPwd, string Password)
        {
            return await Task.Run(() =>
            {
                bool valid = false;

                if (userDetail != null && userDetail.Password.Trim() == Password.Trim())
                    valid = true;

                return valid;
            });
        }
Example #9
0
 public void GiveApproval(ITopNews topNews, IUsers user)
 {
     var objdbhelper = new DBHelper();
     try
     {
         TopNewsDB.Instance.GiveApproval(ref objdbhelper, topNews, user);
     }
     catch (Exception objExp)
     {
         throw objExp;
     }
 }
Example #10
0
 public void MakeActive(ITopNews topNews, IUsers user)
 {
     var objdbhelper = new DBHelper();
     try
     {
         TopNewsDB.Instance.MakeActive(ref objdbhelper, topNews, user);
     }
     catch (Exception objExp)
     {
         throw objExp;
     }
 }
Example #11
0
        public void SetUp()
        {
            _session = Substitute.For<IDataSession>();
            _usersList = new List<User>
                         {
                             new User {Email = "*****@*****.**", DisplayName = "notblocked", Hash= PasswordHash.CreateHash("notblockedpass"), IsBlocked = false},
                             new User {Email = "*****@*****.**", DisplayName = "blocked", Hash= PasswordHash.CreateHash("blockedpass"), IsBlocked = true}
                         };

            _session.Query<User>().Returns(_usersList.AsQueryable());

            _users = new Users(_session);
        }
Example #12
0
 public void GiveApproval(ref DBHelper dbHelper, IInterNews objNews, IUsers user)
 {
     try
     {
         dbHelper.ClearAllParameters();
         dbHelper.AddInParameter("@NewsID", objNews.NewsID, DbType.String);
         dbHelper.AddInParameter("@IsApproved", objNews.IsApproved, DbType.Int32);
         dbHelper.AddInParameter("@UserID", user.UserID, DbType.Int64);
         dbHelper.ExecuteNonQuery(ProcedureName.MakeApprovedInterNews, CommandType.StoredProcedure);
     }
     catch (Exception objExp)
     {
         throw objExp;
     }
 }
Example #13
0
 public void MakeActive(ref DBHelper dbHelper, ITopNews objTopNews, IUsers user)
 {
     try
     {
         dbHelper.ClearAllParameters();
         dbHelper.AddInParameter("@TopNewsID", objTopNews.TopNewsID, DbType.String);
         dbHelper.AddInParameter("@IsActive", objTopNews.IsActive, DbType.Int32);
         dbHelper.AddInParameter("@UserID", user.UserID, DbType.Int64);
         dbHelper.ExecuteNonQuery(ProcedureName.MakeActiveTopNews, CommandType.StoredProcedure);
     }
     catch (Exception objExp)
     {
         throw objExp;
     }
 }
Example #14
0
        public NavigationManager(ISecurityManager securityManager, IConfigurationManager configurationManager, ISolarSystems solarSystems, IShips ships, IJourneyRepository journeyRepository, IUsers userRepository)
        {
            if (securityManager == null) throw new ArgumentNullException("securityManager");
            if (solarSystems == null) throw new ArgumentNullException("solarSystems");
            if (ships == null) throw new ArgumentNullException("ships");
            if (journeyRepository == null) throw new ArgumentNullException("journeyRepository");
            if (configurationManager == null) throw new ArgumentNullException("configurationManager");
            if (userRepository == null) throw new ArgumentNullException("userRepository");

            _securityManager = securityManager;
            _solarSystems = solarSystems;
            _ships = ships;
            _journeyRepository = journeyRepository;
            _configurationManager = configurationManager;
            _userRepository = userRepository;
        }
Example #15
0
 public void GiveApproval(IStateNews news, IUsers user)
 {
     var objdbhelper = DBHelper.Instance;
     try
     {
         StateNewsDB.Instance.GiveApproval(ref objdbhelper, news, user);
     }
     catch (Exception objExp)
     {
         throw objExp;
     }
     finally
     {
         objdbhelper.Dispose();
     }
 }
Example #16
0
        public void GiveApprovalFor(IList<IInterNews> newsList, IUsers user)
        {
            var dbhelper = new DBHelper();
            dbhelper.BeginTransaction();

            try
            {
                newsList.ToList().ForEach(item => InterNewsDB.Instance.GiveApproval(ref dbhelper, item, user));

                dbhelper.CommitTransaction();
            }
            catch (Exception objExp)
            {
                dbhelper.RollbackTransaction();
                throw objExp;
            }
        }
        public BarCodesModule(IUsers users,
            IEventLog eventLog, IBarCodeController barCodeController)
            : base("/BarCode")
        {
            this.RequiresAuthentication();

            this.users = users;
            this.eventLog = eventLog;
            this.barCodeController = barCodeController;

            Get["/{id}"] = x =>
            {
                var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);
                var barcode = this.barCodeController.Get(x.id, userId);
                this.Log(barcode, userId, "GET");
                return Response.AsJson(new[] { barcode });
            };

            Get["/{format}/{code}"] = x =>
                                          {
                                              if (x.format == null || x.code == null)
                                                  return Response.AsJson(Enumerable.Empty<BarCode>());

                                              var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);
                                              BarCode barcode = this.barCodeController.Get(x.format, x.code, userId);
                                              this.Log(barcode, userId, "GET");
                                              return Response.AsJson(new[] {barcode});
                                          };
            Post["/"] = x =>
                            {
                                BarCode barCode = this.Bind<BarCode>();
                                var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);
                                var originalCode = this.barCodeController.Update(barCode, userId);
                                this.Log(originalCode, userId, "UPDATE", barCode.Name);
                                return Response.AsJson(new[] { originalCode });
                            };

            Post["/Rate/{id}/{value}"] = x =>
                                             {
                                                 var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);
                                                 var code = this.barCodeController.Rate(x.id, (Byte)x.value, userId);
                                                 this.Log(x.id, userId, "RATE");
                                                 return Response.AsJson(new[] { code });
                                             };
        }
Example #18
0
        public void Insert(ref DBHelper objdbhelper, ITopNews objTopNews, IImageDetail objImageDetail, IUsers user)
        {
            try
            {
              
                objTopNews.EditorID = "1";
                objTopNews.DisplayOrder = 1;
                objTopNews.IsActive = 0;
                objTopNews.IsApproved = 0;
                objTopNews.LanguageID = 1;

                objImageDetail.IsActive = 0;
                objImageDetail.IsFirst = 1;


                TopNewsDB.Instance.Insert(ref objdbhelper, objTopNews, objImageDetail, user);
            }
            catch (Exception objExp)
            {
                throw objExp;
            }
        }
        public CommentsModule(IBarCodes barCodes, IComments comments, 
            IUsers users, IEventLog eventLog, IGravatarService gravatarService)
            : base("/Comment")
        {
            this.RequiresAuthentication();

            this.barCodes = barCodes;
            this.comments = comments;
            this.users = users;
            this.eventLog = eventLog;
            this.gravatarService = gravatarService;

            Get["/{id}"] = x =>
                               {
                                   if (!this.barCodes.Exists(x.id))
                                       return Response.AsJson(Enumerable.Empty<Comment>());

                                   IEnumerable<Comment> commentsForBarCode = this.comments.GetCommentsForBarCode(x.id);
                                   Comment[] ret =
                                       this.gravatarService.AddAvatarToComments(commentsForBarCode).ToArray();
                                   return Response.AsJson(ret);
                               };

            Post["/{id}"] = x =>
                                {
                                    if (!this.barCodes.Exists(x.id))
                                        return Response.AsJson(Enumerable.Empty<Comment>());

                                    Comment comment = this.Bind<Comment>();
                                    comment.Author = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);

                                    this.comments.Add(comment);
                                    Comment[] commentsForBarCode = this.comments.GetCommentsForBarCode(x.id).ToArray();
                                    this.Log(x.id, comment.Author, "COMMENT", comment.Text);
                                    return Response.AsJson(commentsForBarCode);
                                };
        }
Example #20
0
 /// <summary>
 /// Creates a new user.
 /// </summary>
 /// <remarks>
 /// Required permissions: Users.Create.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='userDto'>
 /// </param>
 public static UserDto Post(this IUsers operations, UserDto userDto)
 {
     return(operations.PostAsync(userDto).GetAwaiter().GetResult());
 }
Example #21
0
 public HomeController(IUsers user, ILog log)
 {
     _user = user;
     _log  = log;
 }
 public UserCommandHandler(IUsers users)
 {
     _users = users;
 }
Example #23
0
        public void MakeActiveFor(IList<IStateNews> newsList, IUsers user)
        {
            var dbhelper = DBHelper.Instance;
            dbhelper.BeginTransaction();

            try
            {
                newsList.ToList().ForEach(item => StateNewsDB.Instance.MakeActive(ref dbhelper, item, user));

                dbhelper.CommitTransaction();
            }
            catch (Exception objExp)
            {
                dbhelper.RollbackTransaction();
                throw objExp;
            }
            finally
            {
                dbhelper.Dispose();
            }
        }
 public TokenController(IUsers users)
 {
     this.users = users;
 }
Example #25
0
 public AccountController(ApplicationContext context, IUsers _users)
 {
     _context = context;
     allUsers = _users;
 }
 public PurchaiseHistoryController(IUsers userRepository)
 {
     repository = userRepository;
 }
Example #27
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='page'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task ListAsync(this IUsers operations, string page = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.ListWithHttpMessagesAsync(page, null, cancellationToken).ConfigureAwait(false);
 }
Example #28
0
 /// <summary>
 /// Deletes a user.
 /// </summary>
 /// <remarks>
 /// Required permissions: Users.Delete.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='ifMatch'>
 /// If-Match header
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task DeleteByIdAsync(this IUsers operations, long id, string ifMatch = default(string), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     (await operations.DeleteByIdWithHttpMessagesAsync(id, ifMatch, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Example #29
0
 /// <summary>
 /// Partially updates a user.
 /// Cannot update roles or organization units via this endpoint.
 /// </summary>
 /// <remarks>
 /// Requires authentication.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='userDto'>
 /// </param>
 public static void PatchById(this IUsers operations, long id, UserDto userDto)
 {
     operations.PatchByIdAsync(id, userDto).GetAwaiter().GetResult();
 }
Example #30
0
 /// <summary>
 /// Deletes a user.
 /// </summary>
 /// <remarks>
 /// Required permissions: Users.Delete.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='ifMatch'>
 /// If-Match header
 /// </param>
 public static void DeleteById(this IUsers operations, long id, string ifMatch = default(string))
 {
     operations.DeleteByIdAsync(id, ifMatch).GetAwaiter().GetResult();
 }
Example #31
0
 /// <summary>
 /// Edits a user.
 /// </summary>
 /// <remarks>
 /// Required permissions: Users.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='userDto'>
 /// </param>
 public static UserDto PutById(this IUsers operations, long id, UserDto userDto)
 {
     return(operations.PutByIdAsync(id, userDto).GetAwaiter().GetResult());
 }
Example #32
0
 /// <summary>
 /// Gets a user based on its id.
 /// </summary>
 /// <remarks>
 /// Requires authentication.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='expand'>
 /// Expands related entities inline.
 /// </param>
 /// <param name='select'>
 /// Selects which properties to include in the response.
 /// </param>
 public static UserDto GetById(this IUsers operations, long id, string expand = default(string), string select = default(string))
 {
     return(operations.GetByIdAsync(id, expand, select).GetAwaiter().GetResult());
 }
Example #33
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task ReadAsync(this IUsers operations, string id, CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.ReadWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false);
 }
 public ChangePasswordController(IUsers userRepository)
 {
     repository = userRepository;
 }
Example #35
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 public static void Read(this IUsers operations, string id)
 {
     Task.Factory.StartNew(s => ((IUsers)s).ReadAsync(id), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
Example #36
0
 /// <summary>
 /// Refreshes user permissions in Power BI.
 /// </summary>
 /// <remarks>
 /// When a user is granted permissions to a workspace, app, or artifact, it
 /// might not be immediately available through API calls.&lt;br/&gt;This
 /// operation refreshes user permissions and makes sure the user permissions
 /// are fully
 /// updated.&lt;br/&gt;&lt;br/&gt;**Important:**&lt;ul&gt;&lt;li&gt;Make the
 /// *refresh user permissions* call, before any other API
 /// calls.&lt;/li&gt;&lt;li&gt;It takes about two minutes for the permissions
 /// to get refreshed. Before calling other APIs, wait for two
 /// minutes.&lt;/li&gt;&lt;/ul&gt;**Required scope:** Workspace.Read.All  or
 /// Workspace.ReadWrite.All&lt;br/&gt;To set the permissions scope, see
 /// [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// &lt;h2&gt;Restrictions&lt;/h2&gt; User can call this API once per hour.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task RefreshUserPermissionsAsync(this IUsers operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.RefreshUserPermissionsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Example #37
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='page'>
 /// </param>
 public static void List(this IUsers operations, string page = default(string))
 {
     Task.Factory.StartNew(s => ((IUsers)s).ListAsync(page), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 public OnTheSpotQueue(IUsers users)
 {
     this.users = users;
 }
Example #39
0
 public void Setup()
 {
     _client   = Credentials.Instance.Client;
     _endpoint = _client.Users;
 }
Example #40
0
 public UsersController(IUsers users)
 {
     _users = users;
 }
Example #41
0
 public HomeController(IUsers users)
 {
     _users = users;
 }
Example #42
0
		private void Users_Reset(int accountId, IUsers users)
		{
			var account = accounts.GetAccount(accountId);
			if (account != null)
				ResetUsers(users, account);
		}
Example #43
0
 public Driver()
 {
     _objects = new Objects();
     _users   = new Users();
     _files   = new Files();
 }
Example #44
0
		private void ResetUsers(IUsers users, IAccount account)
		{
			for (int i = 0; i < users.GetCount(account.Id); i += 100)
			{
				foreach (var user in users.GetUsers(account.Id, i, 100))
					AddOrUpdateUser(user, GetUri(user.Name, account.DomainName));
			}
		}
Example #45
0
 public void UpdateNews(ref DBHelper dbHelper, IStateNews news, IImageDetail image, IUsers user)
 {
     try
     {
         news.EditorID = news.EditorID == null ? String.Empty : news.EditorID;
         StateNewsDB.Instance.Update(ref dbHelper, news, image, user);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #46
0
 public RegisterController(IUsers users, IDataProtectionProvider dataProtectionProvider, DPPurposeStrings dPPurposeStrings)
 {
     dataProtector = dataProtectionProvider.CreateProtector(dPPurposeStrings.ClientIDKey);
     this.users    = users;
 }
Example #47
0
        //public int myDepID;

        static void Main(string[] args)
        {
            int numID;

            if (args.Length != 7)
            {
                Console.WriteLine("Format:  Sample1.exe [department] [First name] [Second name] [email] [from] [until] [code]");
                Console.WriteLine("Example: Sample1.exe visitor_05_16 Joe Bloggs [email protected]  2018-05-01 2018-05-01T07:34:42-5:00 1002");
                return;
            }

            Program main = new Program();

            bool res = main.AuthenticateUser("System engineer", "isaac0904");

            if (res != true)
            {
                Console.WriteLine("Incorrect username or password");
                main.Close();
                return;
            }

            Console.WriteLine("Authentication success");


            IUsers usersSet = main._net2Client.ViewUserRecords(String.Format("Field9_50 = '{0}' AND active=1", args[2]));

            if (usersSet.UsersList().Count > 0)
            {
                Console.WriteLine("xxx Duplicate entry, no thank you!");
                main.Close();
                return;
            }

            //public int Day { get; }
            DateTime now = DateTime.Now;

            Console.WriteLine(now.Month);
            Console.WriteLine(now.Day);

            //string depString = "Visitors_"+ now.Month + "_" + now.Day;
            string depString = args[0];

            Console.WriteLine("department = " + depString);


            //private IDepartments xxx;


            // foreach (DepartmentsSet.DepartmentRow dept in xxx.DepartmentsDataSource.Department)
            //{
            //     Console.WriteLine("department  " + dept.Name + " " + dept.DepartmentID);
            //     Console.WriteLine("department  " + dept.Name + " " + dept.DepartmentID);
            // }

            // delete departments XXXwe need to learn how to remove all users from department

/*
 *          //    foreach (DepartmentsSet.DepartmentRow dept in xxx.DepartmentsDataSource.Department)
 *         // {
 *          //    Console.WriteLine("department xx  " + dept.Name + " " + dept.DepartmentID);
 *              Console.WriteLine("department  " + dept.Name + " " + dept.DepartmentID);
 *
 *              IUsers usersSetDep = main._net2Client.ViewUserRecords("departmentId = '26'");
 *
 *              Console.WriteLine("hererere");
 *
 *              foreach (UsersSet.UserRow u in usersSetDep.UsersDataSource.User)
 *              {
 *                  //   Console.WriteLine("users in dep");
 *
 *
 *              }
 *
 *
 *              //if (usersSetDep.UsersList().Count > 0)
 *              //{
 *              //
 *               //   Console.WriteLine("users in dep");
 *              //}
 *
 *
 *
 *                      bool retdel = main._net2Client.DeleteDepartment(26);
 *              Console.WriteLine("HERE " + retdel);
 *
 *              //if (retdel)
 *              //{
 *              //    Console.WriteLine(" department was delete  " + depString);
 *              //}
 *
 *              retdel = main._net2Client.DeleteDepartment(23);
 *              if (retdel)
 *              {
 *                  Console.WriteLine(" department was delete  " + depString);
 *              }
 *
 *
 *          }
 */

            // add new department

            bool ret = main._net2Client.AddDepartment(depString);

            if (ret)
            {
                Console.WriteLine("New department was added " + depString);
            }

            // get new department ID

            IDepartments xxx = main._net2Client.ViewDepartments();

            numID = 0;

            foreach (DepartmentsSet.DepartmentRow dept in xxx.DepartmentsDataSource.Department)
            {
                //Console.WriteLine("here " + dept.Name + dept.DepartmentID);

                if (dept.Name == depString)
                {
                    //Console.WriteLine("gotit" + dept.DepartmentID);
                    numID = dept.DepartmentID;
                    Console.WriteLine("department ID = " + numID + " for " + depString);
                }
            }

            //Console.WriteLine("numID = " + numID);



            int    accessLevel        = 1; // All hours, all doors
            int    departmentId       = numID;
            bool   antiPassbackInd    = false;
            bool   alarmUserInd       = false;
            string firstName          = args[1];
            string middleName         = null;
            string surname            = args[2];
            string telephoneNo        = null;
            string telephoneExtension = null;
            string pinCode            = args[6];
            string pictureFileName    = null;
            //DateTime activationDate = DateTime.Now;
            DateTime activationDate = DateTime.Parse(args[4]);

            int      cardNumber = 0;
            int      cardTypeID = 0;
            bool     active     = true;
            string   faxNo      = null;
            DateTime expiryDate = DateTime.Parse(args[5]);

            string[] customFields = null;

            Console.WriteLine("New user about to be added " + args[1] + ' ' + args[2] + ' ' + args[6]);


            int userId = main._net2Client.AddNewUser(
                accessLevel, departmentId, antiPassbackInd, alarmUserInd, firstName, middleName, surname,
                telephoneNo, telephoneExtension, pinCode, pictureFileName, activationDate, cardNumber, cardTypeID,
                active, faxNo, expiryDate, customFields
                );

            if (userId == OemClient.ErrorCodes.AddNewUserFailed)
            {
                Console.Write(main._net2Client.LastErrorMessage);
                main.Close();
                return;
            }

            Console.WriteLine("New user was added " + args[1] + ' ' + args[6]);

            // Get list of users in department

            var query = "SELECT * from UsersEx";

            var dataSet = main._net2Client.QueryDb(query);

            foreach (DataRow row in dataSet.Tables[0].Rows)
            {
                Console.Write("row...");
                Console.Write(row["Surname"] + "   ");
                Console.WriteLine(row["DepartmentName"]);
            }

            main.Close();
            return;
        }
Example #48
0
 /// <summary>
 /// Gets users.
 /// </summary>
 /// <remarks>
 /// Required permissions: Users.View.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='expand'>
 /// Expands related entities inline.
 /// </param>
 /// <param name='filter'>
 /// Filters the results, based on a Boolean condition.
 /// </param>
 /// <param name='select'>
 /// Selects which properties to include in the response.
 /// </param>
 /// <param name='orderby'>
 /// Sorts the results.
 /// </param>
 /// <param name='top'>
 /// Returns only the first n results.
 /// </param>
 /// <param name='skip'>
 /// Skips the first n results.
 /// </param>
 /// <param name='count'>
 /// Includes a count of the matching results in the response.
 /// </param>
 public static ODataResponseListUserDto GetUsers(this IUsers operations, string expand = default(string), string filter = default(string), string select = default(string), string orderby = default(string), int?top = default(int?), int?skip = default(int?), bool?count = default(bool?))
 {
     return(operations.GetUsersAsync(expand, filter, select, orderby, top, skip, count).GetAwaiter().GetResult());
 }
Example #49
0
		private void Users_AddedOrUpdated(int accountId, IUsers source, IUser user)
		{
			var account = accounts.GetAccount(accountId);
			if (account != null)
				AddOrUpdateUser(user, GetUri(user.Name, account.DomainName));
		}
Example #50
0
 /// <summary>
 /// Refreshes user permissions in Power BI.
 /// </summary>
 /// <remarks>
 /// When a user is granted permissions to a workspace, app, or artifact, it
 /// might not be immediately available through API calls.&lt;br/&gt;This
 /// operation refreshes user permissions and makes sure the user permissions
 /// are fully
 /// updated.&lt;br/&gt;&lt;br/&gt;**Important:**&lt;ul&gt;&lt;li&gt;Make the
 /// *refresh user permissions* call, before any other API
 /// calls.&lt;/li&gt;&lt;li&gt;It takes about two minutes for the permissions
 /// to get refreshed. Before calling other APIs, wait for two
 /// minutes.&lt;/li&gt;&lt;/ul&gt;**Required scope:** Workspace.Read.All  or
 /// Workspace.ReadWrite.All&lt;br/&gt;To set the permissions scope, see
 /// [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// &lt;h2&gt;Restrictions&lt;/h2&gt; User can call this API once per hour.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static void RefreshUserPermissions(this IUsers operations)
 {
     operations.RefreshUserPermissionsAsync().GetAwaiter().GetResult();
 }
Example #51
0
 /// <summary>
 /// Partially updates a user.
 /// Cannot update roles or organization units via this endpoint.
 /// </summary>
 /// <remarks>
 /// Requires authentication.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='userDto'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PatchByIdAsync(this IUsers operations, long id, UserDto userDto, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     (await operations.PatchByIdWithHttpMessagesAsync(id, userDto, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Example #52
0
 public SetPasswordDialog(IUsers users, User user)
 {
     _users = users;
     _user  = user;
 }
 public TripService(IUsers users, ITripDao tripDao)
 {
     _users = users;
     _tripDao = tripDao;
 }
Example #54
0
 /// <summary>
 /// Returns a user permission collection containing data about the current user
 /// and all the permissions it has.
 /// </summary>
 /// <remarks>
 /// Requires authentication.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static UserPermissionsCollection GetCurrentPermissions(this IUsers operations)
 {
     return(operations.GetCurrentPermissionsAsync().GetAwaiter().GetResult());
 }
Example #55
0
 public static UserManager UserManager(ISecurityManager securityManager = null, IUsers userDataAccess = null)
 {
     return new UserManager(securityManager ?? Mock.Of<ISecurityManager>(),
         userDataAccess ?? Mock.Of<IUsers>());
 }
Example #56
0
 /// <summary>
 /// Returns a user permission collection containing data about the current user
 /// and all the permissions it has.
 /// </summary>
 /// <remarks>
 /// Requires authentication.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <UserPermissionsCollection> GetCurrentPermissionsAsync(this IUsers operations, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.GetCurrentPermissionsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Example #57
0
 public AddUserDialog(IUsers users, long id)
 {
     _users = users;
     _user = new User { Id = id };
 }
Example #58
0
 /// <summary>
 /// Associates/dissociates the given user with/from a role based on toggle
 /// parameter.
 /// </summary>
 /// <remarks>
 /// Required permissions: Users.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='toggleRoleParameters'>
 /// &lt;para /&gt;Toggle - States whether to associate or to dissociate the
 /// role with/from the user.
 /// &lt;para /&gt;Role - The name of the role to be associated/dissociated.
 /// </param>
 public static void ToggleRoleById(this IUsers operations, long id, ToggleRoleParameters toggleRoleParameters)
 {
     operations.ToggleRoleByIdAsync(id, toggleRoleParameters).GetAwaiter().GetResult();
 }
Example #59
0
        public override void Initialize(string name, NameValueCollection config)
        {
            // Initialize values from web.config.
            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "JsProfileProvider";

            if (String.IsNullOrEmpty(config["description"])) {
                config.Remove("description");
                config.Add("description", "Nhibernate Profile provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            _applicationName = GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            WriteExceptionsToEventLog = Convert.ToBoolean(GetConfigValue(config["writeExceptionsToEventLog"], "true"));
            users = WindsorBootStrapper.Container.Kernel.Resolve<IUsers>();
            profiles = WindsorBootStrapper.Container.Kernel.Resolve<IProfiles>();
        }
Example #60
0
 /// <summary>
 /// Associates/dissociates the given user with/from a role based on toggle
 /// parameter.
 /// </summary>
 /// <remarks>
 /// Required permissions: Users.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='toggleRoleParameters'>
 /// &lt;para /&gt;Toggle - States whether to associate or to dissociate the
 /// role with/from the user.
 /// &lt;para /&gt;Role - The name of the role to be associated/dissociated.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task ToggleRoleByIdAsync(this IUsers operations, long id, ToggleRoleParameters toggleRoleParameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     (await operations.ToggleRoleByIdWithHttpMessagesAsync(id, toggleRoleParameters, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }