public AccountTypeDB GetAccountTypeByHostType(HostType hostType) { DBManager db = new DBManager(); string accountTypeName = AccountTypeDB.FromTypeCodeToString(hostType); var accountType = db.GetAccountTypeByName(accountTypeName); return accountType; }
public int DeleteAccountList(List<int> IdList) { DBManager db = new DBManager(); foreach(int id in IdList) { db.DeleteAccountById(id); } return 1; }
// 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; }
// 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; } } }
public int AddNewAccount(string username, string password, int accountTypeId) { DBManager db = new DBManager(); return db.AddNewAccount(username, password, accountTypeId); }
public List<Account> GetAllAccounts() { DBManager db = new DBManager(); return db.GetAllDisplayAccounts(); }
public List<string> GetAllUserNameOfAccounts() { DBManager db = new DBManager(); return db.GetAllUserNameOfAccounts(); }
public bool SetPreferredHostNameOrder(HostContactNameOrder hostContactNameOrder) { DBManager db = new DBManager(); return db.SetPreferredHostNameOrder(hostContactNameOrder); }
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")); } }
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; }
public List<FaxType> GetAllFaxTypeByAccountTypeName() { DBManager db = new DBManager(); return db.GetAllFaxTypeByAccountTypeName(); }
public bool SetPreferredListFaxType(FaxType faxType) { DBManager db = new DBManager(); return db.SetPreferredListFaxType(faxType); }
// fax type public List<FaxTypeDB> GetAllFaxType() { DBManager db = new DBManager(); return db.GetAllFaxType(); }
// fax public List<Fax> GetAllFaxByContactId(int contactId) { DBManager db = new DBManager(); return db.GetAllFaxByContactId(contactId); }
public bool SetAccountDefaultListEmailType(EmailType emailType) { DBManager db = new DBManager(); return db.SetAccountDefaultListEmailType(emailType); }
public int DeleteAccountById(int id) { DBManager db = new DBManager(); return db.DeleteAccountById(id); }
public List<EmailType> GetAllEmailType_EF() { DBManager db = new DBManager(); return db.GetAllEmailTypeEF(); }
protected void AddOrUpdateAccountWhenImportingFromAccount() { DBManager db = new DBManager(); db.AddOrUpdateAccountWhenImportingFromAccount(ref account); }
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; }
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); } }
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); } }
// host name order public List<ContactNameOrder> GetAllNameOrder() { DBManager db = new DBManager(); return db.GetAllNameOrder(); }