Exemplo n.º 1
0
 public AccountTypeDB GetAccountTypeByHostType(HostType hostType)
 {
     DBManager db = new DBManager();
     string accountTypeName = AccountTypeDB.FromTypeCodeToString(hostType);
     var accountType = db.GetAccountTypeByName(accountTypeName);
     return accountType;
 }
Exemplo n.º 2
0
 public int DeleteAccountList(List<int> IdList)
 {
     DBManager db = new DBManager();
     foreach(int id in IdList)
     {
         db.DeleteAccountById(id);
     }
     return 1;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 7
0
 public int AddNewAccount(string username, string password, int accountTypeId)
 {
     DBManager db = new DBManager();
     return db.AddNewAccount(username, password, accountTypeId);
 }
Exemplo n.º 8
0
 public List<Account> GetAllAccounts()
 {
     DBManager db = new DBManager();
     return db.GetAllDisplayAccounts();
 }
Exemplo n.º 9
0
 public List<string> GetAllUserNameOfAccounts()
 {
     DBManager db = new DBManager();
     return db.GetAllUserNameOfAccounts();
 }
Exemplo n.º 10
0
 public bool SetPreferredHostNameOrder(HostContactNameOrder hostContactNameOrder)
 {
     DBManager db = new DBManager();
     return db.SetPreferredHostNameOrder(hostContactNameOrder);
 }
Exemplo n.º 11
0
 public bool SetDefaultHostNameOrder(HostContactNameOrder hostContactNameOrder)
 {
     DBManager db = new DBManager();
     return db.SetDefaultHostNameOrder(hostContactNameOrder);
 }
Exemplo n.º 12
0
        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"));
            }
        }
Exemplo n.º 13
0
 public bool SetPreferredListEmailType(EmailType emailType)
 {
     DBManager db = new DBManager();
     return db.SetPreferredListEmailType(emailType);
 }
Exemplo n.º 14
0
 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"));
     }
 }
Exemplo n.º 15
0
        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;
        }
Exemplo n.º 16
0
 public List<FaxType> GetAllFaxTypeByAccountTypeName()
 {
     DBManager db = new DBManager();
     return db.GetAllFaxTypeByAccountTypeName();
 }
Exemplo n.º 17
0
 public bool SetPreferredListFaxType(FaxType faxType)
 {
     DBManager db = new DBManager();
     return db.SetPreferredListFaxType(faxType);
 }
Exemplo n.º 18
0
 // fax type
 public List<FaxTypeDB> GetAllFaxType()
 {
     DBManager db = new DBManager();
     return db.GetAllFaxType();
 }
Exemplo n.º 19
0
 // fax
 public List<Fax> GetAllFaxByContactId(int contactId)
 {
     DBManager db = new DBManager();
     return db.GetAllFaxByContactId(contactId);
 }
Exemplo n.º 20
0
 public bool SetAccountDefaultListEmailType(EmailType emailType)
 {
     DBManager db = new DBManager();
     return db.SetAccountDefaultListEmailType(emailType);
 }
Exemplo n.º 21
0
 public int DeleteAccountById(int id)
 {
     DBManager db = new DBManager();
     return db.DeleteAccountById(id);
 }
Exemplo n.º 22
0
 public List<EmailType> GetAllEmailType_EF()
 {
     DBManager db = new DBManager();
     return db.GetAllEmailTypeEF();
 }
Exemplo n.º 23
0
 protected void AddOrUpdateAccountWhenImportingFromAccount()
 {
     DBManager db = new DBManager();
     db.AddOrUpdateAccountWhenImportingFromAccount(ref account);
 }
Exemplo n.º 24
0
 public List<HostContactNameOrder> GetHostNameOrder()
 {
     DBManager db = new DBManager();
     return db.GetHostNameOrder();
 }
Exemplo n.º 25
0
        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;
        }
Exemplo n.º 26
0
 public List<EmailType> GetAllEmailTypeByAccountTypeName(string accountTypename)
 {
     DBManager db = new DBManager();
     return db.GetAllEmailTypeByAccountTypeName(accountTypename);
 }
Exemplo n.º 27
0
        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);
            }
        }
Exemplo n.º 28
0
 public bool SetAccountDefaultListFaxType(FaxType faxType)
 {
     DBManager db = new DBManager();
     return db.SetAccountDefaultListFaxType(faxType);
 }
Exemplo n.º 29
0
 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);
     }
 }
Exemplo n.º 30
0
        // host name order

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