Example #1
0
        private static Account LoadFromDb(int id_acct, int id_user, bool with_mailing_lists, string dataFolder)
        {
            Account newAccount;

            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan;

            if (dataFolder == string.Empty)
            {
                dbMan = creator.CreateDbManager();
            }
            else
            {
                dbMan = creator.CreateDbManager(dataFolder);
            }
            try
            {
                dbMan.Connect();
                newAccount = dbMan.SelectAccountData(id_acct, id_user, with_mailing_lists);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(newAccount);
        }
Example #2
0
        public static User CreateUser()
        {
            WebmailResourceManager resMan = (new WebmailResourceManagerCreator()).CreateResourceManager();
            User             newUser      = null;
            DbManagerCreator creator      = new DbManagerCreator();
            DbManager        dbMan        = creator.CreateDbManager();

            try
            {
                dbMan.Connect();

                WebmailSettings settings = (new WebMailSettingsCreator()).CreateWebMailSettings();

                int  LicensesNum = Utils.GetLicensesNum(settings.LicenseKey);
                int  Users       = dbMan.GetUsersCountNotDel();
                bool Deleted     = ((LicensesNum > 0) && (Users >= LicensesNum)) ? true : false;
                if (!Deleted)
                {
                    newUser = dbMan.CreateUser(Deleted);
                }
                else
                {
                    throw new WebMailException(resMan.GetString("ErrorMaximumUsersLicenseIsExceeded"));
                }
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(newUser);
        }
Example #3
0
        public static void DeleteGroup(AddressBookGroup groupToDelete)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.CreateAddressBookGroup(groupToDelete);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #4
0
        public void RenameGroup(string newName)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.UpdateAddressBookGroup(this);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #5
0
        public void Update()
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.UpdateAddressBookContact(this);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #6
0
        public void UpdateUser()
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.UpdateUser(this);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #7
0
        public static void Delete(int id_admin)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.DeleteSubadmin(id_admin);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #8
0
        public void SetSenderSafety(string email, byte safety)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.SetSender(email, safety);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #9
0
        public static void DeleteUserSettings(int id)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.DeleteSettingsData(id);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #10
0
        public byte GetSenderSafety(string email)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                return(dbMan.GetSenderSafety(email, _id));
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #11
0
        public static void UpdateUsersByLicences(int licences_num)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.MarkUsersAsDeletedByLicences(licences_num);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #12
0
        public static User LoadUser(int id)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                return(dbMan.SelectUser(id));
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #13
0
        public static void Update(int id_admin, string login, string password, string description, List <string> domains)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.UpdateSubadmin(id_admin, login, password, description, domains);
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #14
0
        public static void DeleteContact(AddressBookContact contact)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.DeleteAddressBookContacts(new AddressBookContact[] { contact });
            }
            finally
            {
                dbMan.Disconnect();
            }
        }
Example #15
0
        public static AddressBookGroup CreateGroup(AddressBookGroup groupToCreate)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                groupToCreate = dbMan.CreateAddressBookGroup(groupToCreate);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(groupToCreate);
        }
Example #16
0
        public static AddressBookContact CreateContact(AddressBookContact contactToCreate)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                contactToCreate = dbMan.CreateAddressBookContact(contactToCreate);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(contactToCreate);
        }
Example #17
0
        public AccountCollection GetUserAccounts()
        {
            AccountCollection result  = null;
            DbManagerCreator  creator = new DbManagerCreator();
            DbManager         dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                result = dbMan.SelectUserAccounts(_id);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #18
0
        public static int Create(string login, string password, string description, List <string> domains)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            int result = 0;

            try
            {
                dbMan.Connect();
                result = dbMan.CreateSubadmin(login, password, description, domains);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #19
0
        public static int Count(string condition)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            int result = 0;

            try
            {
                dbMan.Connect();
                result = dbMan.GetSubadminCount(condition);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #20
0
        public static User CreateUser(bool Deleted)
        {
            User             newUser = null;
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                newUser = dbMan.CreateUser(Deleted);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(newUser);
        }
Example #21
0
        public static SubadminCollection GetSubadmins(int page, int pageSize, string orderBy, bool asc, string searchCondition)
        {
            DbManagerCreator   creator = new DbManagerCreator();
            DbManager          dbMan   = creator.CreateDbManager();
            SubadminCollection result  = null;

            try
            {
                dbMan.Connect();
                result = dbMan.SelectSubadmins(page, pageSize, orderBy, asc, searchCondition);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #22
0
        public static Subadmin GetSubadmin(string admin)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            Subadmin         result  = null;

            try
            {
                dbMan.Connect();
                result = dbMan.SelectSubadmin(admin);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #23
0
        public static DomainCollection GetDomains(int id_admin)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            DomainCollection result  = new DomainCollection();

            try
            {
                dbMan.Connect();
                result = dbMan.SelectDomainsByAdmin(id_admin);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #24
0
        public static int GetAllUsersCount()
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            int result = 0;

            try
            {
                dbMan.Connect();
                result = dbMan.GetAllUsersCount();
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #25
0
        public static Domain LoadFromDb(int id)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            Domain           dom     = null;

            try
            {
                dbMan.Connect();
                dom = dbMan.SelectDomainData(id);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(dom);
        }
Example #26
0
        public static long GetUserMailboxsSize(int id_user)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            long             result  = 0;

            try
            {
                dbMan.Connect();
                result = dbMan.GetUserMailboxsSize(id_user);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(result);
        }
Example #27
0
        public static void DeleteFromDb(Account acct)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                dbMan.DeleteAccount(acct._id);
            }
            catch (WebMailDatabaseException ex)
            {
                Log.WriteException(ex);
                throw new WebMailDatabaseException((new WebmailResourceManagerCreator()).CreateResourceManager().GetString("PROC_CANT_DEL_ACCT_BY_ID"), ex);
            }
            finally
            {
                dbMan.Disconnect();
            }

            if (acct.MailIncomingProtocol != IncomingMailProtocol.WMServer)
            {
                FileSystem fs = new FileSystem(acct._email, acct._id, true);
                fs.DeleteFolder("");

                fs = new FileSystem(acct._email, acct._id, false);
                fs.DeleteFolder("");
            }

            if (acct.MailIncomingProtocol == IncomingMailProtocol.WMServer)
            {
                WebmailSettings settings = (new WebMailSettingsCreator()).CreateWebMailSettings();
                try
                {
                    if (settings.EnableWmServer && settings.WmAllowManageXMailAccounts)
                    {
                        WMServerStorage storage = new WMServerStorage(acct);
                        storage.DeleteUser(EmailAddress.GetDomainFromEmail(acct.Email), EmailAddress.GetAccountNameFromEmail(acct.MailIncomingLogin));
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteException(ex);
                }
            }
        }
Example #28
0
        public static Domain LoadDomainFromDb(string domainName)
        {
            Domain newDomain;

            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                newDomain = dbMan.SelectDomainData(domainName);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(newDomain);
        }
Example #29
0
        public static Account LoadFromDb(string email, string login, string password)
        {
            Account newAccount;

            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();

            try
            {
                dbMan.Connect();
                newAccount = dbMan.SelectAccountData(email, login, password);
            }
            finally
            {
                dbMan.Disconnect();
            }
            return(newAccount);
        }
Example #30
0
        public static List <int> GetDomainsId(int id_admin)
        {
            DbManagerCreator creator = new DbManagerCreator();
            DbManager        dbMan   = creator.CreateDbManager();
            List <int>       result  = new List <int>();

            try
            {
                dbMan.Connect();
                result = dbMan.SelectSubadminDomains(id_admin);
            }
            finally
            {
                dbMan.Disconnect();
            }

            return(result);
        }