Example #1
0
 public AccountTypeDB GetAccountTypeByHostType(HostType hostType)
 {
     DBManager db = new DBManager();
     string accountTypeName = AccountTypeDB.FromTypeCodeToString(hostType);
     var accountType = db.GetAccountTypeByName(accountTypeName);
     return accountType;
 }
Example #2
0
 public int DeleteAccountList(List<int> IdList)
 {
     DBManager db = new DBManager();
     foreach(int id in IdList)
     {
         db.DeleteAccountById(id);
     }
     return 1;
 }
Example #3
0
        // Account

        public AccountD GetOrAddAccountByAccountText(string accountText, HostType hostType)
        {
            DBManager db = new DBManager();
            string accountTypeName = AccountTypeDB.FromTypeCodeToString(hostType);
            AccountD account = db.GetAccountByUserNameAndAccountTypeName(accountText, accountTypeName);

            if(account == null) // add new
            {
                AccountType type = db.GetAccountTypeByName(accountTypeName);
                int accountID = db.AddNewAccount(accountText, "", type.Id);

                account = db.GetAccountById(accountID);             
            }
            account.HostType = hostType;
            return account;
        }
        public void SaveDatabaseParameters(int contactLimit, int groupLimit)
        {
            DBManager db = new DBManager();

            string saveData = "{";
            saveData += "'contact_limit':" + contactLimit + ",";
            saveData += "'group_limit':" + groupLimit;
            saveData += "}";
            SecurityManager secMng = new SecurityManager();
            saveData = secMng.EncryptText(saveData);

            db.SaveDatabaseParameters(saveData);


            ContactDB.MAX_CONTACT = contactLimit;
            GroupDB.MAX_GROUP = groupLimit;
        }
Example #5
0
        // Account

        public AccountDB GetOrAddAccountByAccountText(string accountText)
        {
            DBManager db = new DBManager();
            HostType hostType = MyUtils.GetHostTypeFromAccount(accountText);
            string accountTypeName = AccountTypeDB.FromTypeCodeToString(hostType);
            AccountDB account = db.GetAccountByUserNameAndAccountTypeName(accountText, accountTypeName);

            if(account.Id <= 0) // add new
            {
                AccountTypeDB type = db.GetAccountTypeByName(accountTypeName);
                int accountID = db.AddNewAccount(accountText, "", type.Id);

                account = db.GetAccountById(accountID);
                account.HostType = hostType;
            }
            account.AccountTypeName = accountTypeName;
            return account;
        }
        public void LoadDatabaseParameters()
        {
            DBManager db = new DBManager();
            string text = db.LoadDatabaseParameters();
            if (!String.IsNullOrEmpty(text))
            {
                SecurityManager secMng = new SecurityManager();
                string json = secMng.DecryptText(text);

                if (!String.IsNullOrEmpty(json))
                {
                    JToken token = null;
                    try
                    {
                        token = JObject.Parse(json);
                    }
                    catch (Exception e)
                    {
                        return;
                    }
                    JToken temp = token.SelectToken("contact_limit");
                    string contact_limit = temp != null ? temp.ToString() : "";
                    temp = token.SelectToken("group_limit");
                    string group_limit = temp != null ? temp.ToString() : "";

                    int limitContact = 500;
                    Int32.TryParse(contact_limit, out limitContact);
                    limitContact = limitContact == 0 ? 500 : limitContact;

                    int limitGroup = 20;
                    Int32.TryParse(group_limit, out limitGroup);
                    limitGroup = limitGroup == 0 ? 20 : limitGroup;

                    ContactDB.MAX_CONTACT = limitContact;
                    GroupDB.MAX_GROUP = limitGroup;
                }
            }
        }
Example #7
0
 public int AddNewAccount(string username, string password, int accountTypeId)
 {
     DBManager db = new DBManager();
     return db.AddNewAccount(username, password, accountTypeId);
 }
Example #8
0
 public List<Account> GetAllAccounts()
 {
     DBManager db = new DBManager();
     return db.GetAllDisplayAccounts();
 }
Example #9
0
 public List<string> GetAllUserNameOfAccounts()
 {
     DBManager db = new DBManager();
     return db.GetAllUserNameOfAccounts();
 }
Example #10
0
 public bool SetPreferredHostNameOrder(HostContactNameOrder hostContactNameOrder)
 {
     DBManager db = new DBManager();
     return db.SetPreferredHostNameOrder(hostContactNameOrder);
 }
Example #11
0
 public bool SetDefaultHostNameOrder(HostContactNameOrder hostContactNameOrder)
 {
     DBManager db = new DBManager();
     return db.SetDefaultHostNameOrder(hostContactNameOrder);
 }
        public void ImportContactsFromListContactDB(List<CMData.Contact> list)
        {
            // save/update database
            DBManager db = new DBManager();
            int res = db.AddOrUpdateContactsFromAccount(list, MultiDownloadController.Instance.accountTypeName, MultiDownloadController.Instance.mode);

            // notify UI
            if (res > 0)
            {
                NotifyDownloadStatus(DownloadStatus.DONE, string.Format(resourceLoader.GetString("import_num_contacts"), res));
            }
            else
            {
                NotifyDownloadStatus(DownloadStatus.DONE, resourceLoader.GetString("no_contact_import"));
            }
        }
Example #13
0
 public bool SetPreferredListEmailType(EmailType emailType)
 {
     DBManager db = new DBManager();
     return db.SetPreferredListEmailType(emailType);
 }
 public void DownloadContacts(int account_type_id, string username, string password, AccountDownloadListener notify)
 {
     DBManager db = new DBManager();
     Account account = db.AddOrUpdateAccountByUserPassAccTypeId(username, password, account_type_id);
     if (account.Id > 0)
     {
         //DownloadContacts(account, notify);
     }
     else
     {
         notify.NotifyStatusByAccountId(-1, DownloadStatus.DATABASE_ERROR, ResourceStringLoader.GetString("database_error"));
     }
 }
        private bool IsMaximumContactExeed(List<ContactDB> list)
        {
            int moreContactCount = list.Count();
            DBManager db = new DBManager();
            currentContactNumber = db.GetTotalContactCount();

            if (currentContactNumber + moreContactCount > ContactDB.MAX_CONTACT)
            {
                DownloadControllerAndData controllerAndData = new DownloadControllerAndData
                {
                    Controller = this,
                    ListData = list
                };
                NotifyDownloadStatus(DownloadStatus.MAXIMUM_CONTACT_EXEED, controllerAndData);
                return true;
            }
            return false;
        }
Example #16
0
 public List<FaxType> GetAllFaxTypeByAccountTypeName()
 {
     DBManager db = new DBManager();
     return db.GetAllFaxTypeByAccountTypeName();
 }
Example #17
0
 public bool SetPreferredListFaxType(FaxType faxType)
 {
     DBManager db = new DBManager();
     return db.SetPreferredListFaxType(faxType);
 }
Example #18
0
 // fax type
 public List<FaxTypeDB> GetAllFaxType()
 {
     DBManager db = new DBManager();
     return db.GetAllFaxType();
 }
Example #19
0
 // fax
 public List<Fax> GetAllFaxByContactId(int contactId)
 {
     DBManager db = new DBManager();
     return db.GetAllFaxByContactId(contactId);
 }
Example #20
0
 public bool SetAccountDefaultListEmailType(EmailType emailType)
 {
     DBManager db = new DBManager();
     return db.SetAccountDefaultListEmailType(emailType);
 }
Example #21
0
 public int DeleteAccountById(int id)
 {
     DBManager db = new DBManager();
     return db.DeleteAccountById(id);
 }
Example #22
0
 public List<EmailType> GetAllEmailType_EF()
 {
     DBManager db = new DBManager();
     return db.GetAllEmailTypeEF();
 }
 protected void AddOrUpdateAccountWhenImportingFromAccount()
 {
     DBManager db = new DBManager();
     db.AddOrUpdateAccountWhenImportingFromAccount(ref account);
 }
Example #24
0
 public List<HostContactNameOrder> GetHostNameOrder()
 {
     DBManager db = new DBManager();
     return db.GetHostNameOrder();
 }
        private bool IsMaximumContactExeed(List<CMData.Contact> list)
        {
            int moreContactCount = list.Count();
            DBManager db = new DBManager();
            currentContactNumber = db.GetTotalContactCount();
            var totalContacts = currentContactNumber + moreContactCount;

            if (currentContactNumber == ContactDB.MAX_LIMITATION)
            {
                DownloadControllerAndData controllerAndData = new DownloadControllerAndData
                {
                    Controller = this,
                    ListData = list
                };

                NotifyDownloadStatus(DownloadStatus.EXCEED_MAXIMUM_LIMIT_CONTACT, controllerAndData);
                return true;
            }
            else
            {
                if (totalContacts > ContactDB.MAX_CONTACT)
                {
                    DownloadControllerAndData controllerAndData = new DownloadControllerAndData
                    {
                        Controller = this,
                        ListData = list
                    };

                    NotifyDownloadStatus(DownloadStatus.EXCEED_CURRENT_LIMIT_CONTACT, controllerAndData);
                    return true;
                }
            }

            return false;
        }
Example #26
0
 public List<EmailType> GetAllEmailTypeByAccountTypeName(string accountTypename)
 {
     DBManager db = new DBManager();
     return db.GetAllEmailTypeByAccountTypeName(accountTypename);
 }
        public void ImportContactsFromListContactDB(List<ContactDB> list)
        {
            // save/update database
            DBManager db = new DBManager();
            int res = db.AddOrUpdateContacts(list);

            // notify UI
            if (res > 0)
            {
                NotifyDownloadStatus(DownloadStatus.DONE, String.Format(CMController.Properties.Resources.import_num_contacts, res));
            }
            else
            {
                NotifyDownloadStatus(DownloadStatus.INFORM, CMController.Properties.Resources.no_contact_added);
            }
        }
Example #28
0
 public bool SetAccountDefaultListFaxType(FaxType faxType)
 {
     DBManager db = new DBManager();
     return db.SetAccountDefaultListFaxType(faxType);
 }
 public void DownloadContacts(int account_type_id, string username, string password, AccountDownloadListener notify)
 {
     DBManager db = new DBManager();
     AccountDB account = db.AddOrUpdateAccountByUserPassAccTypeId(username, password, account_type_id);
     if (account.Id > 0)
     {
         DownloadContacts(account, notify);
     }
     else
     {
         notify.NotifyStatusByAccountId(-1, DownloadStatus.DATABASE_ERROR, CMController.Properties.Resources.database_error);
     }
 }
Example #30
0
        // host name order

        public List<ContactNameOrder> GetAllNameOrder()
        {
            DBManager db = new DBManager();
            return db.GetAllNameOrder();
        }