예제 #1
0
        /// <summary>
        /// 在指定的MFiles服务器中添加登陆账户
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <param name="server">MFiles Server对象 </param>
        internal void CreateMFilesLoginAccount(User user, VaultServer server,
                                               MFLoginAccountType accountType, MFLicenseType licenseType)
        {
            var app = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd,
                                                      MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var accountName = GetAccountName(user);
                var hasAccount  = MfUserUtils.HasLoginAccount(app, accountName);
                if (!hasAccount)
                {
                    var account  = new LoginAccount();
                    var fullName = user.FullName;
                    if (String.IsNullOrEmpty(fullName))
                    {
                        fullName = user.UserName;
                    }
                    account.Set(accountType, user.Domain, user.UserName,
                                MFLoginServerRole.MFLoginServerRoleLogIn, fullName, user.Email, licenseType);
                    app.LoginAccountOperations.AddLoginAccount(account);
                }
            }
            finally
            {
                app.Disconnect(); //todo 多线程时是否对其他会话有影响
            }
        }
예제 #2
0
        public UserInfo GetUserInfo(VaultServer server, string userName)
        {
            var app = MFServerUtility.ConnectToServer(server);

            try
            {
                var la = MfUserUtils.GetLoginAccount(app, userName);
                if (la != null)
                {
                    if (String.IsNullOrEmpty(la.FullName))
                    {
                        la.FullName = userName;
                    }
                    return(new UserInfo {
                        UserName = userName, Email = la.EmailAddress, Fullname = la.FullName
                    });
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("获取登录账户({0})异常:" + ex.Message, userName), ex);
            }
            finally
            {
                app.Disconnect();
            }

            return(null);
        }
예제 #3
0
        public void ChangeVaultUserInfo(User user, VaultServer server)
        {
            var accountName = GetAccountName(user);
            var app         = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd,
                                                              MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var la = MfUserUtils.GetLoginAccount(app, accountName);
                if (la == null)
                {
                    return;
                }
                var needChange = false;
                if (la.FullName != user.FullName)
                {
                    needChange  = true;
                    la.FullName = user.FullName;
                }
                if (la.EmailAddress != user.Email)
                {
                    la.EmailAddress = user.Email;
                    needChange      = true;
                }
                if (needChange)
                {
                    app.LoginAccountOperations.ModifyLoginAccount(la);
                }
            }
            finally
            {
                app.Disconnect();
            }
        }
예제 #4
0
        /// <summary>
        /// 在指定的Vault中添加用户
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <param name="vault">库对象</param>
        public int CreateVaultUser(User user, MFilesVault vault)
        {
            var server = vault.Server;
            var app    = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd,
                                                         MFServerUtility.GetVaultServerLocalIp(vault.Server), server.ServerPort);

            try
            {
                var mVault = app.LogInToVault(vault.Guid);

                return(CreateVaultUser(mVault, user));
            }
            finally
            {
                app.Disconnect();
            }
        }
예제 #5
0
        private IEnumerable <VaultKey> GetUserVaults(string userName, string password, bool isAdUser, VaultServer server)
        {
            var vaults = new List <VaultKey>();

            try
            {
                var serverApp = MFServerUtility.ConnectToServer(userName, password, server.LocalIp,
                                                                server.ServerPort, isAdUser);
                var keys = serverApp.GetOnlineVaults();
                vaults.AddRange(from VaultOnServer key in keys
                                select new VaultKey {
                    Name = key.Name, Guid = key.GUID
                });
                _serverApp = serverApp;
            }
            catch (Exception)
            {
            }
            return(vaults);
        }
예제 #6
0
        public IEnumerable <ProjectHourInfo> GetHourInfo(IEnumerable <VaultKey> vaultKeys, VaultServer server, DateTime?beginDate = null, DateTime?deadline = null)
        {
            var serverApp = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd, server.LocalIp,
                                                            server.ServerPort, false);
            var res = new List <ProjectHourInfo>();

            foreach (VaultKey v in vaultKeys)
            {
                Vault vault = null;
                try
                {
                    vault = serverApp.LogInToVault(v.Guid);
                }
                catch {}
                if (!IsValid(vault))
                {
                    continue;
                }
                var tBudget = GetTotalBudget(vault);
                if (beginDate == null)
                {
                    beginDate = tBudget.BeginDate;
                }
                if (deadline == null)
                {
                    deadline = tBudget.Deadline;
                }
                var hLogs   = GetHourLogs(vault, tBudget.BeginDate, tBudget.Deadline);
                var pBudget = GetPersonalBudgets(vault);
                res.Add(new ProjectHourInfo
                {
                    TotalBudget     = tBudget,
                    HourLogs        = hLogs,
                    PersonalBudgets = pBudget
                });
            }
            serverApp.Disconnect();
            return(res);
        }
예제 #7
0
        public void CreateMFilesLoginAccount(User user, VaultServer server)
        {
            var app = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd, MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var has = MfUserUtils.HasLoginAccount(app, GetAccountName(user));
                if (!has)
                {
                    var accType = MFLoginAccountType.MFLoginAccountTypeWindows;
                    if (string.IsNullOrEmpty(user.Domain))
                    {
                        accType = MFLoginAccountType.MFLoginAccountTypeMFiles;
                    }
                    CreateMFilesLoginAccount(user, app, accType, MFLicenseType.MFLicenseTypeConcurrentUserLicense);
                }
            }
            finally
            {
                app.Disconnect(); //todo 多线程时是否对其他会话有影响
            }
        }
예제 #8
0
        public IList <MfUser> GetMFilesLoginAccounts(VaultServer server)
        {
            var res = new List <MfUser>();
            var app = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd, MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var accs = MfUserUtils.GetLoginAccounts(app);
                res.AddRange(accs.Select(a => new MfUser
                {
                    AccountName = a.AccountName,
                    Domain      = a.DomainName,
                    UserName    = a.UserName,
                    Email       = a.EmailAddress,
                    FullName    = string.IsNullOrEmpty(a.FullName) ? a.UserName : a.FullName
                }));
            }
            finally
            {
                app.Disconnect(); //todo 多线程时是否对其他会话有影响
            }
            return(res);
        }