Exemplo n.º 1
0
        public FtpAccount AddAccount(string Username, string Password, bool IsSuperUser)
        {
            lock (OperationLock)
            {
                var accounts = (from account in context.FtpAccounts
                               where account.Username == Username
                               select account).ToList();
                if (accounts.Count() > 0)
                    return null;

                bool isActive = true;
                DateTime createDate = DateTime.Now;
                string md5Password = FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5");

                FtpAccount ftpAccount = new FtpAccount
                {
                    Username = Username,
                    Password = md5Password,
                    IsSuperUser = IsSuperUser,
                    IsActive = isActive,
                    CreateDate = createDate,
                    PartitionKey = "AzureFtpAccount",
                    RowKey = Username
                };
                context.AddFtpAccount(ftpAccount);

                return ftpAccount;
            }
        }
Exemplo n.º 2
0
 public static void DeleteFtpAccount(FtpAccount ftpAccount)
 {
     var identity = HttpContext.Current.User.Identity;
     if (identity.IsAuthenticated)
     {
         var accountManager = new AccountManager();
         accountManager.DeleteFtpAccount(ftpAccount.Username);
     }
 }
Exemplo n.º 3
0
 public void ActivateAccount(FtpAccount account)
 {
     lock (OperationLock)
     {
         if (account.IsActive == false)
         {
             account.IsActive = true;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 4
0
        public static void UpdateFtpAccount(FtpAccount ftpAccount)
        {
            var identity = HttpContext.Current.User.Identity;
            if (identity.IsAuthenticated)
            {
                var accountManager = new AccountManager();

                string Username = ftpAccount.Username;
                bool isActive = ftpAccount.IsActive;
                bool isSuperUser = identity.Name.ToLower() == AccountManager.AdminUserName ?
                    ftpAccount.IsSuperUser : false;

                accountManager.UpdateFtpAccount(Username, isSuperUser, isActive);
            }
        }
Exemplo n.º 5
0
 public void UpdateFtpAccount(FtpAccount account)
 {
     this.UpdateObject(account);
     this.SaveChanges();
 }
Exemplo n.º 6
0
 public void DeleteFtpAccount(FtpAccount account)
 {
     this.DeleteObject(account);
     this.SaveChanges();
 }
Exemplo n.º 7
0
 public void AddFtpAccount(FtpAccount account)
 {
     this.AddObject("AzureFtpAccount", account);
     this.SaveChanges();
 }