Esempio n. 1
0
        private void OutLookContactsGridManager(bool GetFreshData = false, bool BindDataToGrid = true)
        {
            ExchangeWebServices   exchangeWebService;
            List <OutlookContact> outlookContacts;

            //
            // If it's the first time of requesting outlook contacts or a new refreshed version is requested.
            if (GetFreshData == true || outlookImportedContacts == null)
            {
                var adlib    = new CCC.UTILS.Libs.AdLib();
                var attr     = adlib.GetUserAttributes(sipAccount);
                var upn      = attr.Upn.Split('@').ToList();
                var username = sipAccount.Split('@').ToList().First().ToLower();
                //var password = encryptionLib.DecryptRijndael(CurrentSession.EncryptedPassword);
                outlookImportedContacts = new List <PhoneBookContact>();

                if (upn.Count > 1)
                {
                    exchangeWebService = new ExchangeWebServices(
                        username,
                        encryptionLib.DecryptRijndael(CurrentSession.EncryptedPassword),
                        upn[1].ToLower()
                        );

                    outlookContacts         = exchangeWebService.OutlookContacts;
                    outlookImportedContacts = new List <PhoneBookContact>();

                    foreach (var outlookContact in outlookContacts)
                    {
                        //Add the business phone 1
                        if (!string.IsNullOrEmpty(outlookContact.BusinessPhone1))
                        {
                            outlookImportedContacts.Add((new PhoneBookContact(0, sipAccount, "Personal", outlookContact.Name, outlookContact.BusinessPhone1, "N/A")));
                        }

                        //Add the business phone 2
                        if (!string.IsNullOrEmpty(outlookContact.BusinessPhone2))
                        {
                            outlookImportedContacts.Add((new PhoneBookContact(0, sipAccount, "Personal", outlookContact.Name, outlookContact.BusinessPhone2, "N/A")));
                        }

                        //Add the home phone 1
                        if (!string.IsNullOrEmpty(outlookContact.HomePhone1))
                        {
                            outlookImportedContacts.Add((new PhoneBookContact(0, sipAccount, "Personal", outlookContact.Name, outlookContact.HomePhone1, "N/A")));
                        }

                        //Add the home phone 2
                        if (!string.IsNullOrEmpty(outlookContact.HomePhone2))
                        {
                            outlookImportedContacts.Add((new PhoneBookContact(0, sipAccount, "Personal", outlookContact.Name, outlookContact.HomePhone2, "N/A")));
                        }

                        //Add the mobile phone
                        if (!string.IsNullOrEmpty(outlookContact.MobilePhone))
                        {
                            outlookImportedContacts.Add((new PhoneBookContact(0, sipAccount, "Personal", outlookContact.Name, outlookContact.MobilePhone, "N/A")));
                        }
                    }
                } //end-if-upn
            }     //end-if-refresh-is-true


            if (BindDataToGrid == true)
            {
                ImportContactsFromOutlookGrid.GetStore().DataSource = outlookImportedContacts;
                ImportContactsFromOutlookGrid.GetStore().DataBind();
            }
        }
Esempio n. 2
0
 protected void AddressbookTabsPanel_TabChange(object send, DirectEventArgs e)
 {
     AddressBookGrid.GetStore().Reload();
     ImportContactsFromHistoryGrid.GetStore().Reload();
     ImportContactsFromOutlookGrid.GetStore().Reload();
 }